【发布时间】:2020-11-29 04:01:09
【问题描述】:
我正在使用 Xamarin Forms Maps,我希望在 iOS 上拥有与在 Android 设备上相同的功能 - 在屏幕上显示所有图钉(适当的位置和缩放)
我看的是“Bounds”属性,但我只在 XF.GoogleMaps 上找到了我不使用的 nuget。
对于 Android,我在我的自定义渲染器中撅嘴 LatLngBounds 类并创建了一个构建器,这工作得很好,但在 iOS 上我没有找到解决方案。
谢谢
更新 #1: 这是 iOS 渲染器中放置 ShowAnnotations 的正确方法吗?以及如何将其从 Pin 模型重新打包到 MkAnnotation 中?
protected override void OnElementChanged(ElementChangedEventArgs<View> e)
{
base.OnElementChanged(e);
if (e.OldElement != null)
{
var nativeMap = Control as MKMapView;
nativeMap.GetViewForAnnotation = null;
nativeMap.ZoomEnabled = true;
nativeMap.CalloutAccessoryControlTapped -= OnCalloutAccessoryControlTapped;
nativeMap.DidSelectAnnotationView -= OnDidSelectAnnotationView;
nativeMap.DidDeselectAnnotationView -= OnDidDeselectAnnotationView;
}
if (e.NewElement != null)
{
var formsMap = (CustomMap)e.NewElement;
var nativeMap = Control as MKMapView;
customPins = formsMap.CustomPins;
//MKAnnotation an = formsMap.CustomPins;
var numberOfPins = formsMap.CustomPins.Count;
MKAnnotation[] anotationArray = new MKAnnotation[numberOfPins];
for (int i = 0; i < numberOfPins; i++)
{
anotationArray[0].Coordinate = customPins.ElementAt(0).Position...
}
foreach (var pin in formsMap.CustomPins)
{
}
nativeMap.ZoomEnabled = true;
nativeMap.GetViewForAnnotation = GetViewForAnnotation;
nativeMap.CalloutAccessoryControlTapped += OnCalloutAccessoryControlTapped;
nativeMap.DidSelectAnnotationView += OnDidSelectAnnotationView;
nativeMap.DidDeselectAnnotationView += OnDidDeselectAnnotationView;
}
}
【问题讨论】:
-
设置区域属性
标签: xamarin xamarin.forms xamarin.ios