Android 如何获取Xamarin表单中地图中心的位置(纬度、经度)
我参与了一个Xamarin表单和OpenStreetMap的项目。 我正试着在地图的中心找到坐标 这是我创建地图的代码Android 如何获取Xamarin表单中地图中心的位置(纬度、经度),android,ios,xamarin,xamarin.forms,openstreetmap,Android,Ios,Xamarin,Xamarin.forms,Openstreetmap,我参与了一个Xamarin表单和OpenStreetMap的项目。 我正试着在地图的中心找到坐标 这是我创建地图的代码 public static Map CreateMap(double latitud, double longitud) { map = new Map(); var location = new Point(longitud, latitud); var sphericalMercatorCoordinate = SphericalMercator.From
public static Map CreateMap(double latitud, double longitud)
{
map = new Map();
var location = new Point(longitud, latitud);
var sphericalMercatorCoordinate = SphericalMercator.FromLonLat(location.X, location.Y);
map.Layers.Add(OpenStreetMap.CreateTileLayer());
map.Home = n => n.NavigateTo(sphericalMercatorCoordinate, map.Resolutions[15]);
return map;
}
这是我在xaml文件中的代码
<maps:MapView x:Name="MapView"
TouchMove="MapView_TouchMove"
MyLocationFollow="True"
IsMyLocationButtonVisible="False"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand" />
所以,尝试添加一个方法MapClicked,以便从“MapView\u TouchMove”调用此方法,但我不知道如何调用
private void MapView_MapClicked(object sender, MapClickedEventArgs e)
{
var lat = e.Point.Latitude;
}
有什么想法吗。。???
谢谢。查看API文档,似乎会返回您想要的内容
根据地图中所有图层的范围获取地图的范围
图层集合
MapView
控件有一个Map
属性,您可以从中获取Envelope
查看API文档,它似乎会返回您想要的内容
根据地图中所有图层的范围获取地图的范围
图层集合
MapView
控件有一个Map
属性,您可以从中获取Envelope
如果您链接到正在使用Added my code创建地图的实际地图控件,这将很有帮助。我正在使用OpenStreetMap我知道你在使用OpenStreetMap。我假设您正在使用一些Nuget包作为控件,我要求您提供一个指向它的链接-谢谢。。!!如果您链接到正在使用的实际地图控件,则会很有帮助添加创建地图的“我的代码”。我正在使用OpenStreetMap我知道你在使用OpenStreetMap。我假设您正在使用一些Nuget包作为控件,我要求您提供一个指向它的链接-谢谢。。!!
private void MapView_MapClicked(object sender, MapClickedEventArgs e)
{
var lat = e.Point.Latitude;
}