尝试使用GetAddressesForPositionAsync()以查找我的坐标也可以指向的可能地址列表。我使用esri ArcGIS映射调用地图并将其添加到mapview
Esri.ArcGISRuntime.Mapping.Map myMap = new Esri.ArcGISRuntime.Mapping.Map(SpatialReference.Create(4326));
myMapView = new Esri.ArcGISRuntime.Xamarin.Forms.MapView();
geoCoder = new Geocoder();
//assign the map to a mapview
myMapView.Map = myMap;
然后使用事件处理程序等待用户双击屏幕。
//event handler
myMapView.GeoViewDoubleTapped += new EventHandler<Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs>(geotappedMap);
//the location for the pin and sent to geothings()
double Lat = ((((Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs)e).Location.X));
double Lng = ((((Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs)e).Location.Y));
myLocation = new MapPoint(Lat, Lng);
程序在那里放置一个标记,然后使用水龙头调用获取位置的坐标。
public async void geothings(Object sender, EventArgs e, Position p)
{
try
{
var possibleAddresses = await geoCoder.GetAddressesForPositionAsync(p);
foreach (var address in possibleAddresses)
_label2.Text += "\n\n" + address;
}
catch (Exception ex)
{
await MainPage.DisplayAlert("Error Getting Address", ex.Message, "Close");
}
}
该功能可以毫无问题地运行,但标签会更新为“南极洲&#39;被叫之后。有谁知道为什么或如何发生这种情况?