Exemple #1
0
        /// <summary>
        /// Zooms to the given list of markers.
        /// </summary>
        /// <param name="markers"></param>
        /// <param name="percentage"></param>
        public void ZoomToMarkers(List <MapMarker> markers, double percentage)
        {
            float height = this.SurfaceHeight;
            float width  = this.SurfaceWidth;

            if (width > 0)
            {
                PointF2D[] points = new PointF2D[markers.Count];
                for (int idx = 0; idx < markers.Count; idx++)
                {
                    points [idx] = new PointF2D(this.Map.Projection.ToPixel(markers [idx].Location));
                }
                View2D view       = this.CreateView();
                View2D fittedView = view.Fit(points, percentage);

                float zoom = (float)this.Map.Projection.ToZoomLevel(fittedView.CalculateZoom(
                                                                        width, height));
                GeoCoordinate center = this.Map.Projection.ToGeoCoordinates(
                    fittedView.Center [0], fittedView.Center [1]);

                this.SetMapView(center, this.MapTilt, zoom);
            }
            else
            {
                _latestZoomCall = new MapViewMarkerZoomEvent()
                {
                    Markers    = markers,
                    Percentage = percentage
                };
            }
        }
Exemple #2
0
        /// <summary>
        /// Zooms to the given list of markers.
        /// </summary>
        /// <param name="markers"></param>
        public void ZoomToMarkers(List<MapMarker> markers, double percentage, bool notifyChange)
        {
            float height = this.Height;
            float width = this.Width;
            if (width > 0) {
                PointF2D[] points = new PointF2D[markers.Count];
                for (int idx = 0; idx < markers.Count; idx++) {
                    points [idx] = new PointF2D (this.Map.Projection.ToPixel (markers [idx].Location));
                }
                View2D view = this.CreateView ();
                View2D fittedView = view.Fit (points, percentage);

                float zoom = (float)this.Map.Projection.ToZoomLevel (fittedView.CalculateZoom (
                                             width, height));
                GeoCoordinate center = this.Map.Projection.ToGeoCoordinates (
                                                       fittedView.Center [0], fittedView.Center [1]);

                if (notifyChange) {
                    this.SetMapView (center, this.MapTilt, zoom, true);
                    this.NotifyMovement ();
                    this.Change ();
                } else {
                    this.SetMapView (center, this.MapTilt, zoom, false);
                }
            } else {
                _latestZoomCall = new MapViewMarkerZoomEvent()
                {
                    Markers = markers,
                    Percentage = percentage
                };
            }
        }