C# Xamarin-GoogleMap类移动到特定位置
在Xamarin的内置C# Xamarin-GoogleMap类移动到特定位置,c#,google-maps,xamarin,C#,Google Maps,Xamarin,在Xamarin的内置Map类中,您可以使用Map.MoveToRegion(新位置(纬度、经度))函数转到地图上的某个区域。我使用的是GoogleMapnuget包,似乎找不到类似的内置函数。谷歌地图的GoogleMap插件是否有此功能,如果有,是什么功能 GoogleMap gMap = new GoogleMap(); //gMap.MoveToRegion(New Position(34.9820, 138.5160)); <-- something like this Goog
Map
类中,您可以使用Map.MoveToRegion(新位置(纬度、经度))
函数转到地图上的某个区域。我使用的是GoogleMap
nuget包,似乎找不到类似的内置函数。谷歌地图的GoogleMap
插件是否有此功能,如果有,是什么功能
GoogleMap gMap = new GoogleMap();
//gMap.MoveToRegion(New Position(34.9820, 138.5160)); <-- something like this
GoogleMap gMap=newgooglemap();
//gMap.MoveToRegion(新位置(34.9820138.5160)) 你可以移动相机
var latlng = new LatLng(34.9820, 138.5160);
gMap.MoveCamera(CameraUpdateFactory.NewLatLng(latlng));
要移动区域,请使用下面的代码,其中
gMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(Latitude, Longitude), Xamarin.Forms.GoogleMaps.Distance.FromMiles(5)));
并使用moveCamera将两点调整到边界(手机屏幕)
其中5是填充
var bounds = Xamarin.Forms.GoogleMaps.Bounds.FromPositions(gMap.Polylines.SelectMany(poly => poly.Positions));
var newBoundsArea = CameraUpdateFactory.NewBounds(bounds, 5);
await gMap.MoveCamera(newBoundsArea);