PowerShell ile Azure Maps Konum Servisleri Kullanımı

Azure Maps, harita, konum ve coğrafi analiz servisleri sunar. PowerShell ile adresi koordinata dönüştürme, mesafe hesaplama ve ısı haritası verisi üretme gibi görevleri otomatize edebilirsiniz.

Azure Maps Hesabı Oluşturmak

PowerShell

$rg        = "newrg-"
$mapsName  = "myAzureMaps"
$location  = "global"
 
New-AzMapsAccount -ResourceGroupName $rg -Name $mapsName `
    -Location $location -SkuName G2
 
$key = (Get-AzMapsAccountKey -ResourceGroupName $rg -Name $mapsName).PrimaryKey
Write-Host "Azure Maps hazır. Anahtar: $($key.Substring(0,15))..."
 

Adres Geocoding

PowerShell

$address = "10 Downing Street, London, UK"
$url     = "https://atlas.microsoft.com/search/address/json?api-version=1.0&subscription-key=$key&query=$([Uri]::EscapeDataString($address))"
 
$result  = Invoke-RestMethod -Uri $url -Method Get
$best    = $result.results[0]
 
Write-Host "Adres: $($best.address.freeformAddress)"
Write-Host "Koordinat: $($best.position.lat), $($best.position.lon)"

 

İki Nokta Arası Mesafe Hesaplamak

PowerShell

$origin = "51.5074,-0.1278"  # Londra
$dest   = "51.4779,-0.0015"  # Greenwich
 
$routeUrl = "https://atlas.microsoft.com/route/directions/json?api-version=1.0&subscription-key=$key&query=$($origin):$($dest)"
$route = Invoke-RestMethod -Uri $routeUrl -Method Get
 
$summary = $route.routes[0].summary
Write-Host "Mesafe: $([math]::Round($summary.lengthInMeters / 1000, 2)) km"
Write-Host "Tahmini süre: $([math]::Round($summary.travelTimeInSeconds / 60, 0)) dakika"