Xamarin表单 - Google地图在地图上显示多个标记
问题描述:
我正在使用Android.Gms.Maps.GoogleMap
在我的Xamarin表单应用android项目中显示地图。我无法找到很多关于在特定的经度和纬度显示(理想情况下)屏幕上的文档,或者(理想情况下)标记引脚的文档。Xamarin表单 - Google地图在地图上显示多个标记
是否有像GoogleMap.addMarker(double latitude, double longitude)
或类似的功能来显示这样的圆或针?
答
要添加谷歌地图上用圆圈验证码:
Circle circle;
public void OnMapReady (GoogleMap googleMap)
{
map = googleMap;
var circleOptions = new CircleOptions();
circleOptions.InvokeCenter (new LatLng (lat, lon));
circleOptions.InvokeRadius (circle.Radius);
circleOptions.InvokeFillColor (0X66FF0000);
circleOptions.InvokeStrokeColor (0X66FF0000);
circleOptions.InvokeStrokeWidth (1);
circle = map.AddCircle (circleOptions);
}
要添加标记使用此:
Marker marker;
public void OnMapReady (GoogleMap googleMap)
{
MarkerOptions markerOpt1 = new MarkerOptions();
markerOpt1.SetPosition(new LatLng(lat, lon));
markerOpt1.SetTitle("testing");
marker = googleMap.AddMarker(marker1);
}
为避免多次标记,圈你可以编辑自己的位置,而不做一个新的:
circle.Center = new LatLng(latLng.Latitude, latLng.Longitude);
marker.Position = new LatLng(latLng.Latitude, latLng.Longitude);
+0
谢谢雷,这是一个很好的答案 –
+0
欢迎您:) – Rai
有'AddMarker(MarkerOptions)'方法,请看这里:https://developer.xamarin.com/guides/android/platform_f eatures/maps_and_location/maps/part_2 _-_ maps_api/ –
感谢Daniel,不敢相信我错过了! –