ThinkGeo Cloud
ThinkGeo UI Controls
ThinkGeo Open Source
Help and Support
External Resources
ThinkGeo Cloud
ThinkGeo UI Controls
ThinkGeo Open Source
Help and Support
External Resources
using System.Collections.Generic; using System.Collections.ObjectModel; using ThinkGeo.MapSuite.Core; namespace MiniMapAdornmentLayerWithGoogleMap { public class MiniMapAdornmentLayer : AdornmentLayer { private Collection<Layer> layers; private int width; private int height; public MiniMapAdornmentLayer() : this(new Layer[] { }, 100, 100) { } public MiniMapAdornmentLayer(int width, int height) : this(new Layer[] { }, width, height) { } public MiniMapAdornmentLayer(IEnumerable<Layer> layers, int width, int height) { this.layers = new Collection<Layer>(); foreach (Layer layer in layers) { this.layers.Add(layer); } this.width = width; this.height = height; } public Collection<Layer> Layers { get { return layers; } } public int Width { get { return width; } set { width = value; } } public int Height { get { return height; } set { height = value; } } protected override void DrawCore(GeoCanvas canvas, Collection<SimpleCandidate> labelsInAllLayers) { GeoImage miniImage = new GeoImage(width, height); RectangleShape scaledWorldExtent = MapEngine.GetDrawingExtent(canvas.CurrentWorldExtent, width, height); scaledWorldExtent.ScaleUp(300); GdiPlusGeoCanvas minCanvas = new GdiPlusGeoCanvas(); minCanvas.BeginDrawing(miniImage, scaledWorldExtent, canvas.MapUnit); foreach (Layer layer in layers) { layer.Draw(minCanvas, labelsInAllLayers); } minCanvas.DrawArea(RectangleShape.ScaleDown(minCanvas.CurrentWorldExtent, 1), new GeoPen(GeoColor.StandardColors.Gray, 2), DrawingLevel.LevelOne); minCanvas.DrawArea(canvas.CurrentWorldExtent, new GeoPen(GeoColor.StandardColors.Black, 2), DrawingLevel.LevelOne); minCanvas.EndDrawing(); ScreenPointF drawingLocation = GetDrawingLocation(canvas, width, height); canvas.DrawScreenImageWithoutScaling(miniImage, (drawingLocation.X + width / 2) + 10, (drawingLocation.Y + height / 2) - 10, DrawingLevel.LevelOne, 0, 0, 0); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; namespace MiniMapAdornmentLayerWithGoogleMap { static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new TestForm()); } } }
using System; using System.Windows.Forms; using System.Collections.ObjectModel; using ThinkGeo.MapSuite.Core; using ThinkGeo.MapSuite.DesktopEdition; namespace MiniMapAdornmentLayerWithGoogleMap { public partial class TestForm : Form { public TestForm() { InitializeComponent(); } private void TestForm_Load(object sender, EventArgs e) { // Set the full extent and the background color winformsMap1.MapUnit = GeographyUnit.Meter; winformsMap1.CurrentExtent = new RectangleShape(-13939426.6371, 6701997.4056, -7812401.86, 2626987.386962); GoogleMapsLayer googleMapLayer = new GoogleMapsLayer(); LayerOverlay layeroverlay = new LayerOverlay(); layeroverlay.Layers.Add(googleMapLayer); winformsMap1.Overlays.Add(layeroverlay); MiniMapAdornmentLayer miniMapLayer = new MiniMapAdornmentLayer(); miniMapLayer.Location = AdornmentLocation.LowerLeft; miniMapLayer.Layers.Add(new BackgroundLayer(winformsMap1.BackgroundOverlay.BackgroundBrush)); miniMapLayer.Layers.Add(googleMapLayer); winformsMap1.AdornmentOverlay.Layers.Add(miniMapLayer); winformsMap1.Refresh(); } private void winformsMap1_MouseMove(object sender, MouseEventArgs e) { //Displays the X and Y in screen coordinates. statusStrip1.Items["toolStripStatusLabelScreen"].Text = "X:" + e.X + " Y:" + e.Y; //Gets the PointShape in world coordinates from screen coordinates. PointShape pointShape = ExtentHelper.ToWorldCoordinate(winformsMap1.CurrentExtent, new ScreenPointF(e.X, e.Y), winformsMap1.Width, winformsMap1.Height); //Displays world coordinates. statusStrip1.Items["toolStripStatusLabelWorld"].Text = "(world) X:" + Math.Round(pointShape.X, 4) + " Y:" + Math.Round(pointShape.Y, 4); } private void btnClose_Click(object sender, EventArgs e) { this.Close(); } } }