Skip to content

Instantly share code, notes, and snippets.

@leeberg
Last active September 16, 2019 23:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leeberg/53e86bc79126baeb050551a343d1598f to your computer and use it in GitHub Desktop.
Save leeberg/53e86bc79126baeb050551a343d1598f to your computer and use it in GitHub Desktop.
PowersShell BingMapsLatLongFromAddress
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