2

I went through this Microsoft documentation and trying to resolve the address (Country, State, City) from the geo-coordinates (lat, long):

https://learn.microsoft.com/en-us/dotnet/api/system.device.location.civicaddressresolver?view=netframework-4.8

This is my script which gives me the exact geo-coordinates but unable to resolve the city, country, state from it:

Add-Type -AssemblyName System.Device #Required to access System.Device.Location namespace
$watcher = New-object System.Device.Location.GeoCoordinateWatcher
$watcher.Start()
$watcher.Status #NoData
$watcher.Permission #Granted

while (($watcher.Status -ne 'Ready') -and ($watcher.Permission -ne 'Denied')) {
    Write-Host 'Entering while loop'
    Start-Sleep -Milliseconds 1000 #Wait for discovery.
}
if ($watcher.Permission -eq 'Denied'){
    Write-Host 'Access Denied for Location Information'
} else {


    $location = $watcher.Position.Location
    Write-Host $location # Lat, Long printed - See Output
    $AddressResolver = New-Object System.Device.Location.CivicAddressResolver
    $AddressResolver.ResolveAddress($location) #IsUnknown : True

}

Output:

enter image description here

Any help will be greatly appreciated.

dig_123
  • 2,240
  • 6
  • 35
  • 59
  • Seems you have the same problem as [this question](https://stackoverflow.com/questions/53202259/civicaddressresolver-always-returning-unknown). The answer indicated that .Net 4.8 doesn't implement CivicAddressResolver, and suggests a workaround of using Google Maps API. – Rich Moss Mar 24 '21 at 18:42

0 Answers0