Last active
September 16, 2019 23:15
-
-
Save leeberg/53e86bc79126baeb050551a343d1598f to your computer and use it in GitHub Desktop.
PowersShell BingMapsLatLongFromAddress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-BingMapsLatLongFromAddress | |
{ | |
param ( | |
[String] $AddressLine, | |
[String] $CountryCode, | |
[String] $AdminState, | |
[String] $AdminCity | |
) | |
$BingMapsKey = 'Your_Key_Goes_Here' | |
$URI = "http://dev.virtualearth.net/REST/v1/Locations/"+$CountryCode+"/"+$AdminState+"/"+$AdminCity+"/"+$AddressLine+"?inclnb=1&MaxResults=1&key=$BingMapsKey" | |
$WebData = Invoke-WebRequest -Method Get -Uri $URI -UseBasicParsing | |
$WebDataContentObject = $WebData.Content | ConvertFrom-Json | |
$Coords = $WebDataContentObject.resourceSets.resources.point.coordinates | |
$CoordinateObject = [PSCustomObject]@{ | |
Latitude = $Coords[0] | |
Longitude = $Coords[1] | |
} | |
return $CoordinateObject | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment