예제 #1
0
 protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
 {
     base.OnElementPropertyChanged(sender, e);
     if (e.PropertyName == MapView.CenterProperty.PropertyName)
     {
         if (!ReferenceEquals(Element.Center, currentCamera))
         {
             if (Element.Center == null)
             {
                 return;
             }
             FocustoLocation(Element.Center.ToLatLng());
         }
     }
     else if (e.PropertyName == MapView.MapStyleProperty.PropertyName && map != null)
     {
         UpdateMapStyle();
     }
     else if (e.PropertyName == MapView.PitchEnabledProperty.PropertyName)
     {
         if (map != null)
         {
             map.UiSettings.TiltGesturesEnabled = Element.PitchEnabled;
         }
     }
     else if (e.PropertyName == MapView.PitchProperty.PropertyName)
     {
         map?.SetTilt(Element.Pitch);
     }
     else if (e.PropertyName == MapView.RotateEnabledProperty.PropertyName)
     {
         if (map != null)
         {
             map.UiSettings.RotateGesturesEnabled = Element.RotateEnabled;
         }
     }
     else if (e.PropertyName == MapView.RotatedDegreeProperty.PropertyName)
     {
         map?.SetBearing(Element.RotatedDegree);
     }
     else if (e.PropertyName == MapView.AnnotationsProperty.PropertyName)
     {
         RemoveAllAnnotations();
         if (Element.Annotations != null)
         {
             AddAnnotations(Element.Annotations.ToArray());
             var notifyCollection = Element.Annotations as INotifyCollectionChanged;
             if (notifyCollection != null)
             {
                 notifyCollection.CollectionChanged += OnAnnotationsCollectionChanged;
             }
         }
     }
     else if (e.PropertyName == MapView.ZoomLevelProperty.PropertyName && map != null)
     {
         var dif = Math.Abs(map.CameraPosition.Zoom - Element.ZoomLevel);
         System.Diagnostics.Debug.WriteLine($"Current zoom: {map.CameraPosition.Zoom} - New zoom: {Element.ZoomLevel}");
         if (dif >= 0.01)
         {
             System.Diagnostics.Debug.WriteLine("Updating zoom level");
             map.AnimateCamera(CameraUpdateFactory.ZoomTo(Element.ZoomLevel));
         }
     }
 }