Example #1
0
        /// <summary>
        /// Changes the Center, Heading and ZoomLevel properties according to the specified
        /// viewport coordinate translation, rotation and scale delta values. Rotation and scaling
        /// is performed relative to the specified center point in viewport coordinates.
        /// </summary>
        public void TransformMap(Point center, Vector translation, double rotation, double scale)
        {
            if (rotation != 0d || scale != 1d)
            {
                transformCenter = MapProjection.ViewportPointToLocation(center);
                viewportCenter  = center + translation;

                if (rotation != 0d)
                {
                    var heading = (((Heading + rotation) % 360d) + 360d) % 360d;
                    SetValueInternal(HeadingProperty, heading);
                    SetValueInternal(TargetHeadingProperty, heading);
                }

                if (scale != 1d)
                {
                    var zoomLevel = Math.Min(Math.Max(ZoomLevel + Math.Log(scale, 2d), MinZoomLevel), MaxZoomLevel);
                    SetValueInternal(ZoomLevelProperty, zoomLevel);
                    SetValueInternal(TargetZoomLevelProperty, zoomLevel);
                }

                UpdateTransform(true);
            }
            else
            {
                TranslateMap(translation); // more precise
            }
        }
Example #2
0
        /// <summary>
        /// Changes the Center property according to the specified translation in viewport coordinates.
        /// </summary>
        public void TranslateMap(Vector translation)
        {
            if (transformCenter != null)
            {
                ResetTransformCenter();
                UpdateTransform();
            }

            if (translation.X != 0d || translation.Y != 0d)
            {
                Center = MapProjection.ViewportPointToLocation(viewportCenter - translation);
            }
        }
Example #3
0
 /// <summary>
 /// Sets a temporary center point in viewport coordinates for scaling and rotation transformations.
 /// This center point is automatically reset when the Center property is set by application code.
 /// </summary>
 public void SetTransformCenter(Point center)
 {
     transformCenter = MapProjection.ViewportPointToLocation(center);
     viewportCenter  = center;
 }
Example #4
0
 /// <summary>
 /// Transforms a Point in viewport coordinates to a Location in geographic coordinates.
 /// </summary>
 public Location ViewportPointToLocation(Point point)
 {
     return(MapProjection.ViewportPointToLocation(point));
 }