====== Source Code DesktopEditionSample ShapefileToGoogleMap CS 100609.zip ====== ====Program.cs==== using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; namespace ShapefileToGoogleMap { static class Program { /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new TestForm()); } } } ====TestForm.cs==== using System; using System.Windows.Forms; using System.Collections.ObjectModel; using ThinkGeo.MapSuite.Core; using ThinkGeo.MapSuite.DesktopEdition; namespace ShapefileToGoogleMap { public partial class TestForm : Form { public TestForm() { InitializeComponent(); } private void TestForm_Load(object sender, EventArgs e) { //We need to set the map unit to meter because we are using Google Map Spherical Mercator projection. winformsMap1.MapUnit = GeographyUnit.Meter; winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromArgb(255, 198, 255, 255)); //Sets Google Map as the background map. GoogleMapsOverlay googleMapsOverlay = new GoogleMapsOverlay(); winformsMap1.Overlays.Add(googleMapsOverlay); //Projection to go from Geodetic (Longitude/Latitude) to Google Map projection (Spherical Mercator). Proj4Projection proj4 = new Proj4Projection(); proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326); //Geodetic projection (Longitude/Latitude). proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString(); ShapeFileFeatureLayer schoolShapeLayer = new ShapeFileFeatureLayer(@"..\..\Data\austinschools.shp"); schoolShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.CreateSimplePointStyle(PointSymbolType.Circle, GeoColor.StandardColors.Red,GeoColor.StandardColors.Black, 9); schoolShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateMaskTextStyle("NAME", new GeoFont("Arial", 10, DrawingFontStyles.Bold), new GeoSolidBrush(GeoColor.StandardColors.Black), new AreaStyle(new GeoSolidBrush(GeoColor.StandardColors.LightGoldenrodYellow)), 13, 0); schoolShapeLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; //Sets the projection to the shapefile layer. schoolShapeLayer.FeatureSource.Projection = proj4; LayerOverlay staticOverlay = new LayerOverlay(); staticOverlay.Layers.Add("SchoolShapeLayer", schoolShapeLayer); winformsMap1.Overlays.Add(staticOverlay); //Sets the extent of the map as the bounding box of the shapefile layer as projected (Google Map Spherical Mercator). schoolShapeLayer.Open(); winformsMap1.CurrentExtent = schoolShapeLayer.GetBoundingBox(); schoolShapeLayer.Close(); 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(); } } }