示例#1
0
        private void CenterPointPropertyChanged(Point centerPoint)
        {
            if (!internalPropertyChange)
            {
                var center = MapProjection.PointToLocation(centerPoint);
                center.Longitude = Location.NormalizeLongitude(center.Longitude);

                InternalSetValue(CenterProperty, center);
                UpdateTransform();
            }
        }
示例#2
0
        /// <summary>
        /// Sets the TargetZoomLevel and TargetCenter properties so that the specified bounding box
        /// fits into the current viewport. The TargetHeading property is set to zero.
        /// </summary>
        public void ZoomToBounds(BoundingBox boundingBox)
        {
            var rect   = MapProjection.BoundingBoxToRect(boundingBox);
            var center = new Point(rect.X + rect.Width / 2d, rect.Y + rect.Height / 2d);
            var scale  = Math.Min(RenderSize.Width / rect.Width, RenderSize.Height / rect.Height)
                         * MapProjection.TrueScale / MapProjection.PixelPerDegree;

            TargetZoomLevel = Math.Log(scale, 2d);
            TargetCenter    = MapProjection.PointToLocation(center);
            TargetHeading   = 0d;
        }
示例#3
0
        /// <summary>
        /// Sets the TargetZoomLevel and TargetCenter properties so that the specified bounding box
        /// fits into the current viewport. The TargetHeading property is set to zero.
        /// </summary>
        public void ZoomToBounds(BoundingBox boundingBox)
        {
            if (boundingBox != null && boundingBox.HasValidBounds)
            {
                var rect     = MapProjection.BoundingBoxToRect(boundingBox);
                var center   = new Point(rect.X + rect.Width / 2d, rect.Y + rect.Height / 2d);
                var scale0   = 1d / MapProjection.GetViewportScale(0d);
                var lonScale = scale0 * RenderSize.Width / rect.Width;
                var latScale = scale0 * RenderSize.Height / rect.Height;
                var lonZoom  = Math.Log(lonScale, 2d);
                var latZoom  = Math.Log(latScale, 2d);

                TargetZoomLevel = Math.Min(lonZoom, latZoom);
                TargetCenter    = MapProjection.PointToLocation(center);
                TargetHeading   = 0d;
            }
        }