Ejemplo n.º 1
0
 /// <summary>Centers the map on the specified coordinates.</summary>
 /// <param name="latitude">The latitude cooridinate.</param>
 /// <param name="longitude">The longitude coordinates.</param>
 /// <param name="zoom">The zoom level for the map.</param>
 public void Center(double latitude, double longitude, int zoom)
 {
     this.BeginUpdate();
     this.Zoom = zoom;
     _offsetX.CenterOn(TileGenerator.GetTileX(longitude, this.Zoom));
     _offsetY.CenterOn(TileGenerator.GetTileY(latitude, this.Zoom));
     this.EndUpdate();
 }
Ejemplo n.º 2
0
        /// <summary>Centers the map on the specified coordinates, calculating the required zoom level.</summary>
        /// <param name="latitude">The latitude cooridinate.</param>
        /// <param name="longitude">The longitude coordinates.</param>
        /// <param name="size">The minimum size that must be visible, centered on the coordinates.</param>
        public void Center(double latitude, double longitude, Size size)
        {
            double left   = TileGenerator.GetTileX(longitude - (size.Width / 2.0), 0);
            double right  = TileGenerator.GetTileX(longitude + (size.Width / 2.0), 0);
            double top    = TileGenerator.GetTileY(latitude - (size.Height / 2.0), 0);
            double bottom = TileGenerator.GetTileY(latitude + (size.Height / 2.0), 0);

            double height = (top - bottom) * TileGenerator.TileSize;
            double width  = (right - left) * TileGenerator.TileSize;
            int    zoom   = Math.Min(TileGenerator.GetZoom(this.ActualHeight / height), TileGenerator.GetZoom(this.ActualWidth / width));

            this.Center(latitude, longitude, zoom);
        }
Ejemplo n.º 3
0
 private void RepositionChildren()
 {
     foreach (UIElement element in this.Children)
     {
         double latitude  = GetLatitude(element);
         double longitude = GetLongitude(element);
         if (latitude != double.PositiveInfinity && longitude != double.PositiveInfinity)
         {
             double x = (TileGenerator.GetTileX(longitude, this.Zoom) - _offsetX.Tile) * TileGenerator.TileSize;
             double y = (TileGenerator.GetTileY(latitude, this.Zoom) - _offsetY.Tile) * TileGenerator.TileSize;
             Canvas.SetLeft(element, x);
             Canvas.SetTop(element, y);
             element.RenderTransform = _translate;
         }
     }
 }