есть ли в Windows Phone API геокодер? - PullRequest
2 голосов
/ 09 марта 2012

Как преобразовать географическую координату в адрес в Windows Phone?В Android это возможно через android.location.Geocoder.

1 Ответ

3 голосов
/ 09 марта 2012

Это, безусловно, должно помочь вам :) Также сделал извлечение из этого блога в нижней части этого сообщения, чтобы вы знали, если это то, что вы ищете.

http://www.dizzey.com/development/net/getting-started-windows-phone-7-getting-location-reverse-geocoding-weather/


Получите файл System.Device.dll, который содержит API геокода.

//Instantiate 
GeoCoordinateWatcher watcher = null;
watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.Default);
watcher.PositionChanged += 
    new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(OnPositionChanged);
watcher.Start();

//Use
void OnPositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)    
{
    //stop & clean up, we don’t need it anymore
    watcher.Stop();
    watcher.Dispose();
    watcher = null;   
    location = e.Position.Location;
}

и геокодирование:

var reverseGeocodeRequest = new ReverseGeocodeRequest();

// Set the credentials using a valid Bing Maps key
reverseGeocodeRequest.Credentials = new BingMaps.Credentials();    
reverseGeocodeRequest.Credentials.ApplicationId = "ENTER YOUR BING MAPS KEY HERE";

// Set the point to use to find a matching address    
BingMaps.Location point = new BingMaps.Location();
point.Latitude = location.Latitude;
point.Longitude = location.Longitude;

reverseGeocodeRequest.Location = point;

// Make the reverse geocode request
GeocodeServiceClient geocodeService = new  
    GeocodeServiceClient("BasicHttpBinding_IGeocodeService");

geocodeService.ReverseGeocodeCompleted += new
    EventHandler<ReverseGeocodeCompletedEventArgs>
        (geocodeService_ReverseGeocodeCompleted);

geocodeService.ReverseGeocodeAsync(reverseGeocodeRequest);
...