GMap.ToString
With the ToString method of the GMap class, you can gather the Javascript that is going to produce our map.
Thanks to this, we facilitated things like getting the Javascript that we are going to work with in a server event.
It is enough to initialize the GMap class with GMap_Id, and soon we can add everything to it we want: controls, markers, infowindows, etc. The example is totally academic (click on the map):
Code.aspx
<cc1:GMap ID="GMap1" runat="server" enableServerEvents="True" OnClick="GMap1_Click" />
Code.aspx.cs
protected string GMap1_Click(object s, Subgurim.Controles.GAjaxServerEventArgs e)
{
GMap gmap = new GMap(e.map);
// GMarker and GInfoWindow
GMarker marker = new GMarker(e.point);
GInfoWindow window = new GInfoWindow(marker, "Cool!!", true);
gmap.Add(window);
// Movement
//gmap.addMovement(1000, e.point + new GLatLng(25, 38));
//gmap.addMovement(1000, e.point);
// Polylines
if (e.point != e.center)
{
List points = new List();
points.Add(e.center);
points.Add(e.point);
gmap.addPolyline(new GPolyline(points, Color.Yellow));
}
// Controls
gmap.addControl(new GControl(GControl.extraBuilt.MarkCenter));
gmap.addControl(new GControl(GControl.preBuilt.LargeMapControl));
gmap.addControl(new GControl(GControl.preBuilt.MapTypeControl));
// Maybe... anything? ;)
gmap.enableScrollWheelZoom = false;
gmap.mapType = GMapType.GTypes.Satellite;
return gmap.ToString();
}