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; using System.Configuration; using ThinkGeo.MapSuite.Core; using ThinkGeo.MapSuite.WebEdition; namespace GPStoGoogleMap { public partial class TestForm : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#E5E3DF")); //Sets the projection parameters to go from Geodetic (EPSG 4326) or decimal degrees to Google Map projection (Spherical Mercator). Proj4Projection proj4 = new Proj4Projection(); proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326);//Geodetic (decimal degrees). proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();// Google Map projection (Spherical Mercator) //Maximum and minimum longitude and latitude values the map to be centered on. //Here we are centering on Florida. double minx = -88.0656; //Mininum Longitude double miny = 24.6526; //Minimum Latitude double maxx = -79.0724; //Maximum Longitude double maxy = 31.3938; //Maximum Latitude //Gets the RectangleShape in the Google Map projection. proj4.Open(); RectangleShape googleMapRectangleShape = proj4.ConvertToExternalProjection(new RectangleShape(minx, maxy, maxx, miny)); proj4.Close(); //Sets the extent of the map according to the projected RectangleShape. //Notice that a snap to closest zoom level will occur. The map will be centered based on that RectangleShape //and it will snap to the closest zoom level to fit the RectangleShape. Map1.CurrentExtent = googleMapRectangleShape; Map1.MapUnit = GeographyUnit.Meter; Map1.MapTools.OverlaySwitcher.Enabled = true; Map1.MapTools.MouseCoordinate.Enabled = true; //Adds the Google Map as an overlay GoogleOverlay google = new GoogleOverlay("Google Map"); google.JavaScriptLibraryUri = new Uri(ConfigurationManager.AppSettings["GoogleUri"]); google.GoogleMapType = GoogleMapType.Normal; Map1.CustomOverlays.Add(google); } } } }
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TestForm.aspx.cs" Inherits="GPStoGoogleMap.TestForm" %> <%@ Register Assembly="WebEdition" Namespace="ThinkGeo.MapSuite.WebEdition" TagPrefix="cc1" %> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <link href="~/theme/default/samplepic/style.css" rel="stylesheet" type="text/css" /> <title>Use Google Map</title> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <cc1:Map ID="Map1" runat="server" Height="100%" Width="100%"> </cc1:Map> <%-- <description:descriptionpanel ID="DescPanel" runat="server"> This sample displays a google map. Click buttons below to switch between different Google maps. <br /> <br /> <asp:Button CssClass="btn" ID="btnRoad" runat="server" Text="Normal" OnClientClick="Map1.SetCurrentBackgroundMapType(G_NORMAL_MAP); return false;" /> <asp:Button CssClass="btn" ID="btnAerial" runat="server" Text="Hybrid" OnClientClick="Map1.SetCurrentBackgroundMapType(G_HYBRID_MAP); return false;" /> <br /> <asp:Button CssClass="btn" ID="btnSatellite" runat="server" Text="Satellite" OnClientClick="Map1.SetCurrentBackgroundMapType(G_SATELLITE_MAP); return false;" /> <asp:Button CssClass="btn" ID="btnPhysical" runat="server" Text="Physical" OnClientClick="Map1.SetCurrentBackgroundMapType(G_PHYSICAL_MAP); return false;" /> </description:descriptionpanel>--%> </form> </body> </html>