protected override void OnItemPropertyChanged(object sender, PropertyChangedEventArgs e) { Circle item = (Circle)sender; BMKCircle native = (BMKCircle)item?.NativeObject; if (null == native) { return; } if (Annotation.TitleProperty.PropertyName == e.PropertyName) { native.Title = item.Title; return; } if (Annotation.CoordinateProperty.PropertyName == e.PropertyName) { native.Coordinate = item.Coordinate.ToNative(); return; } if (Circle.RadiusProperty.PropertyName == e.PropertyName) { native.Radius = item.Radius; return; } if (Circle.WidthProperty.PropertyName == e.PropertyName) { BMKCircleView view = (BMKCircleView)NativeMap.ViewForAnnotation(native); if (view != null) { view.LineWidth = item.Width; } return; } if (Circle.ColorProperty.PropertyName == e.PropertyName) { BMKCircleView view = (BMKCircleView)NativeMap.ViewForAnnotation(native); if (view != null) { view.StrokeColor = item.Color.ToUIColor(); } return; } if (Circle.FillColorProperty.PropertyName == e.PropertyName) { BMKCircleView view = (BMKCircleView)NativeMap.ViewForAnnotation(native); if (view != null) { view.FillColor = item.Color.ToUIColor(); } return; } }
protected override void OnItemPropertyChanged(object sender, PropertyChangedEventArgs e) { Pin item = (Pin)sender; BMKPointAnnotation native = (BMKPointAnnotation)item?.NativeObject; if (null == native) { return; } if (Annotation.CoordinateProperty.PropertyName == e.PropertyName) { native.Coordinate = item.Coordinate.ToNative(); return; } if (Annotation.TitleProperty.PropertyName == e.PropertyName) { native.Title = string.IsNullOrEmpty(item.Title) ? "" : item.Title; // 防止空白气泡弹出 BMKPinAnnotationView view = (BMKPinAnnotationView)NativeMap.ViewForAnnotation(native); if (view != null) { view.CanShowCallout = !string.IsNullOrEmpty(item.Title); } return; } if (Pin.ImageProperty.PropertyName == e.PropertyName) { BMKPinAnnotationView view = (BMKPinAnnotationView)NativeMap.ViewForAnnotation(native); if (view != null) { view.Image = item.Image.ToNative(); } return; } if (Pin.DraggableProperty.PropertyName == e.PropertyName) { BMKPinAnnotationView view = (BMKPinAnnotationView)NativeMap.ViewForAnnotation(native); if (view != null) { view.Draggable = item.Draggable; } return; } }
protected override void OnItemPropertyChanged(object sender, PropertyChangedEventArgs e) { Polyline item = (Polyline)sender; BMKPolyline native = (BMKPolyline)item?.NativeObject; if (null == native) { return; } if (Annotation.TitleProperty.PropertyName == e.PropertyName) { native.Title = item.Title; return; } if (Polyline.PointsProperty.PropertyName == e.PropertyName) { CLLocationCoordinate2D[] points = new CLLocationCoordinate2D[item.Points.Count]; for (int i = 0; i < points.Length; i++) { points[i] = item.Points[i].ToNative(); } native.SetPolylineWithCoordinates(ref points[0], points.Length); return; } if (Polyline.WidthProperty.PropertyName == e.PropertyName) { BMKPolylineView view = NativeMap.ViewForAnnotation(native); if (view != null) { view.LineWidth = item.Width; } return; } if (Polyline.ColorProperty.PropertyName == e.PropertyName) { BMKPolylineView view = NativeMap.ViewForAnnotation(native); if (view != null) { view.StrokeColor = item.Color.ToUIColor(); } return; } }