protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);
            System.Diagnostics.Debug.WriteLine("MapViewRenderer:" + e.PropertyName);
            if (e.PropertyName == MapView.RegionProperty.PropertyName)
            {
                OnMapRegionChanged();
                return;
            }

            if (e.PropertyName == MapView.CenterProperty.PropertyName)
            {
                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?.AnimateCamera(CameraUpdateFactory.TiltTo(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?.AnimateCamera(CameraUpdateFactory.BearingTo(Element.RotatedDegree));
            }
            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 && cameraBusy == false)
                {
                    System.Diagnostics.Debug.WriteLine("Updating zoom level");
                    map.AnimateCamera(CameraUpdateFactory.ZoomTo(Element.ZoomLevel));
                }
            }
        }
Beispiel #2
0
        protected override void OnElementPropertyChanged(object sender,
                                                         System.ComponentModel.PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);

            if (e.PropertyName == MapView.VisibleBoundsProperty.PropertyName)
            {
                OnMapRegionChanged();
            }
            else if (e.PropertyName == MapView.CenterProperty.PropertyName)
            {
                FocustoLocation(new LatLng(Element.Center.Lat, Element.Center.Long));
            }
            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?.AnimateCamera(CameraUpdateFactory.TiltTo(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?.AnimateCamera(CameraUpdateFactory.BearingTo(Element.RotatedDegree));
            }
            else if (e.PropertyName == MapView.ZoomLevelProperty.PropertyName && map != null)
            {
                if (Element.ZoomLevel.HasValue == false)
                {
                    return;
                }

                var dif = Math.Abs(map.CameraPosition.Zoom - Element.ZoomLevel.Value);
                System.Diagnostics.Debug.WriteLine(
                    $"Current zoom: {map.CameraPosition.Zoom} - New zoom: {Element.ZoomLevel}");
                if (dif >= double.Epsilon && cameraBusy == false)
                {
                    System.Diagnostics.Debug.WriteLine("Updating zoom level");
                    map.AnimateCamera(CameraUpdateFactory.ZoomTo(Element.ZoomLevel.Value));
                }
            }
            else if (e.PropertyName == MapView.AnnotationsProperty.PropertyName)
            {
            }
            else if (e.PropertyName == MapView.RenderTextureModeProperty.PropertyName)
            {
                // TODO Set RenderTextureModeProperty
            }
            else if (e.PropertyName == MapView.RenderTextureTranslucentSurfaceProperty.PropertyName)
            {
                // TODO Set RenderTextureTranslucentSurfaceProperty
            }
        }