Пожалуйста, проверьте документ Выполните геокодирование и обратное геокодирование . Мы должны указать карты ключ аутентификации , прежде чем вы сможете использовать картографические сервисы. Для использования картографического сервиса нам также необходимо включить возможность определения местоположения .
И вы можете проверить свойство MapLocationFinderResult
Status
, чтобы убедиться, что запрос успешно выполнен.
MapService.ServiceToken = "Token";
MapLocationFinderResult result =
await MapLocationFinder.FindLocationsAsync(
BuildingNumber + ", " + PostCode, null);
if (result.Status == MapLocationFinderStatus.Success)
{
var Text = "result = (" +
result.Locations[0].Point.Position.Latitude.ToString() + "," +
result.Locations[0].Point.Position.Longitude.ToString() + result.Locations[0].DisplayName + ")";
}
Если указанный выше адрес не содержит названия улицы, вы можете использовать широту и долготу, чтобы изменить геокод, а затем вызвать FindLocationsAtAsync
метод для получения адреса.
MapLocationFinderResult result =
await MapLocationFinder.FindLocationsAsync(
BuildingNumber + ", " + PostCode, null);
if (result.Status == MapLocationFinderStatus.Success)
{
var temp = "result = (" +
result.Locations[0].Point.Position.Latitude.ToString() + "," +
result.Locations[0].Point.Position.Longitude.ToString() + result.Locations[0].DisplayName + result.Locations[0].Address.Street + ")";
BasicGeoposition location = new BasicGeoposition();
location.Latitude = result.Locations[0].Point.Position.Latitude;
location.Longitude = result.Locations[0].Point.Position.Longitude;
Geopoint pointToReverseGeocode = new Geopoint(location);
// Reverse geocode the specified geographic location.
MapLocationFinderResult MyResult =
await MapLocationFinder.FindLocationsAtAsync(pointToReverseGeocode);
// If the query returns results, display the name of the town
// contained in the address of the first result.
if (result.Status == MapLocationFinderStatus.Success)
{
var text = "Street = " +
MyResult.Locations[0].Address.Street;
}
}