Project Description

Wraps Google Maps API as ASP.NET custom control.
Offers extremely easy and fast way of adding Google Maps API support on your ASP.NET pages.

Features
  • ASP.NET AJAX (under UpdatePanel) enabled;
  • Loading by Geocoding or Latitude/Longitude;
  • Google Map Marker(s);
    • set by Geocoding or Latitude/Longitude;
    • simple text for the info window;
    • InfoWindowContent template for adding any html and asp.net controls to markers' info window;
    • Dragable;
    • Custom Icons;
    • OpenInfoBehaviour - to change the default behaviour of opening info window on marker click (available: Click, DoubleClick, MouseDown, MouseOut, MouseOver, MouseUp);
  • Polylines;
  • Polygons;
  • Traffic Overlays;
  • Driving Directions (look at the sample page for the issue with localhost usage);
  • Capture map click point position;
  • GoogleBar for address search on the maps;
  • Marker Manager for maps with a lot of markers;
  • Goecoding locations caching and persistence on postback for map and markers;
  • DefaultView control property to manage the map initial view with support to all google map types since Google API 2.9 (Normal, Satellite, Hybrid, Physical, MoonElevation, MoonVisible, MarsElevation, MarsVisible, MarsInfrared, SkyVisible);
  • GoogleMap Events client-side/server-side handling;
  • GoogleMarker Events client-side/server-side handling;
  • Static Map as image that can be saved;
  • Circle Polygon - you can easy add circle polygons to the GoogleMap control;
  • Data Binding - you can set any supported DataSource to GoogleMap control for binding markers to data;
  • Actions - server-side methods fire client-side code invokation, for example you can call GoogleMap1.OpenInfoWindowHtml method of GoogleMap which will open an info window on client-side when map is loaded;

Known Issues
  • When using Google Maps on localhost they can work with not properly obtained keys (even that given in the samples here), but in order to work without problems you have to obtain a key for the desired domain;
  • Driving direction will not appear on localhost, but on the public site/domain for which you have obtained the key, they will be shown properly (That is probably protection or security issue of Google Maps API). Check out next discussion: Getting around the Google API Key Issue on localhost
  • When using GoogleMap control inside ASP.NET AJAX TabPanel you have to set size of the control in pixels (not in percents) in order to get control working properly;
  • Static map will not work on localhost. Check out Getting around the Google API Key Issue on localhost ;
  • The max size of the static map is 512x512. Code cuts it if is greater, otherwise static map will not work;
  • Only markers are supported for static map - no traffic, no overlays, no directions etc. This is like it is - that's just provided by Google Maps API. There is no as I can see so far support for custom makers icons as well. So, the standard markers' icons are used only on the static map;
  • If you want to show polylines on your map (like the lines used by Google Maps to show driving directions), you need to include the VML namespace in your XHTML document to make everything work properly in Internet Explorer. The beginning of your XHTML document should look like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">


Future enhancements
  • Advanced marker data binding with template;
  • Labeled Markers and switching (show/hide) by label;
  • Google Map Overlays support;
  • Google Map Controls support;
  • Google Polygon Events support;
  • Google Polyline Events support;

Downloads

Help Topics

News

Project Links

Team Blogs


Happy coding ...
Last edited Dec 18 2008 at 9:03 AM by velio, version 92
Comments
Also available: 2 reviews for current release.

Jinx101 wrote  Jan 3 2008 at 9:19 PM 
I've only been looking at this for about 10 minutes but I'm really impressed, I had maps up and running in no time with only a few lines of code. Good job man, very handy code that will save a lot of time for basic mapping needs!

saudaziz wrote  Jan 23 2008 at 4:11 AM 
Is there any sample application WITH source code that one could use to see how we are supposed to set these all programatically?

velio wrote  Jan 23 2008 at 6:49 AM 
Hi, I'll produce a code examples of how to use GoogleMap control as soon as I find some free time :(.
Basically you can set any property of the control in the code.
You can add markers or directions in the code to the Markers and Directions collections of the control, as well.
However code example is comming soon.

saudaziz wrote  Jan 23 2008 at 5:07 PM 
Thanks for the quick response. I was looking though the code for the control and figured how i could make the map refresh depending on user's actions. Basically, i have application where user selects state and all the locations related to that state appear with markers on them. While i was able to set the markers and all other properties, i was unsure as to how i could make the map refresh with the new information. To achieve that, i am using Anthem AJAX toolkit and passing in this:

Anthem.Manager.AddScriptForClientSideEval("Artem.Web.GoogleMap.loadGeo('GoogleMap2',{width:700,height:480,zoom:9,traffic:false,typeControl:true,enableGoogleBar:false,zoomPanType:0,address:'" + dr["Address"].ToString() + "'});Artem.Web.GoogleMap.setupGeoMarker('GoogleMap2','" + dr["Address"].ToString() + "', '" + dr["CustomerAddress"].ToString() + "');");

Does that look like the right approach to refresh the map with new values?

velio wrote  Jan 24 2008 at 4:52 PM 
Hi, I see. Why not. I think it is possible to do it that way. You actually adding the result script lines.
However, you can do it in pure C# code. Here is the example how that should look like in C# code:

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page {

protected void Page_Load(object sender, EventArgs e) {

GoogleMap2.Width = new Unit("700px");
GoogleMap2.Height = new Unit("480px");
GoogleMap2.Zoom = 9;
GoogleMap2.ShowTraffic = false;
GoogleMap2.ShowMapTypeControl = true;
GoogleMap2.EnableGoogleBar = false;
GoogleMap2.ZoomPanType = Artem.Web.UI.Controls.ZoomPanType.Small;
GoogleMap2.Address = dr["Address"].ToString();
Artem.Web.UI.Controls.GoogleMarker marker = new Artem.Web.UI.Controls.GoogleMarker();
marker.Address = dr["Address"].ToString();
marker.Text = dr["CustomerAddress"].ToString();
GoogleMap2.Markers.Add(marker);
}
}

Hope this helps ...

saudaziz wrote  Jan 25 2008 at 12:46 AM 
Yes. Thanks.

phyo wrote  Feb 12 2008 at 7:15 AM 
How can I capture Latitude, Longitude position after dragend?

I saw somewhere (http://www.wotton.org/map/getlatlng.html), the source code is like that:
GEvent.addListener(marker, "dragend", function() {
document.getElementById('lat').value = marker.getPoint().lat();
document.getElementById('lng').value = marker.getPoint().lng();
});

velio wrote  Feb 12 2008 at 2:18 PM 
Comming in next release 2.8

unruledboy wrote  Feb 28 2008 at 4:00 AM 
localized map data? I am in China, google uses different map data from local map company. how to set it?

velio wrote  Feb 28 2008 at 7:16 AM 
Work Item was created for localized map data (see: http://www.codeplex.com/googlemap/WorkItem/View.aspx?WorkItemId=3843) and soon will be available thanks to Jeroen.

vivati wrote  Mar 15 2008 at 11:52 PM 
Control specs look great! Are there any built in methods for creating circles? thanks.

velio wrote  Mar 17 2008 at 10:36 PM 
Hi, check out this issue: http://www.codeplex.com/googlemap/WorkItem/View.aspx?WorkItemId=4082. Regards

kunalghate wrote  Aug 19 2008 at 11:04 PM 
Hi, I have added a draggable marker on gMap and at the drag end event, I want to get the lat lng of the point. Can this be done on server side? Please let me know. Thanks!

Rahmoon wrote  Sep 8 2008 at 11:47 AM 
Hi, I have added few markers and one of the marker has got dragend event but for some reason when control is firing this event and going back to server, it is throwing exception and when I have looked at code, found that this.Markers haven't got anything in it which means it has lost the markers some how? Could you please let me know what I am doing wrong. FYI: I have already enabled the viewstate for the control but no luck. Your response will be highly appreciated. Many Thanks

e6h2w wrote  Sep 19 2008 at 2:14 PM 
Does anyone know how to change the image on the marker from the default red marker to a custom image?

jonroberts1972 wrote  Nov 30 2008 at 10:05 AM 
HI,
I am using this control and I want to draw a polyline from coordinates that I have stored in a database. When I load in the coordinates, make them into points, place them on the map and draw the polyline, the code breaks in the Javascript code. It is because the code is called before the map is generated. If I have a click button on the page which creates the same polyline it works fine. How can I create a line on the page load before the map is loaded? I am using ASP.NET, VB. Thanks Jon..... sample code below

Dim line As New Artem.Web.UI.Controls.GooglePolyline()
line.Color = Drawing.Color.Red
line.Weight = 3
GoogleMap1.Zoom = 14
Dim points As String() = lineString.Split(";"c)
For Each point As String In points
If point <> "" Then
line.Points.Add(GoogleLocation.Parse(point))
End If

Next

GoogleMap1.Polylines.Clear()
GoogleMap1.Polylines.Add(line)

Updating...
© 2006-2009 Microsoft | About CodePlex | Privacy Statement | Terms of Use | Code of Conduct | CodePlex Blog | Version 2008.12.9.14291