Anonymous user  |  Log in  |  Create Account


With the ToString method of the GMap class, you can obtain the Javascript that is going to produce our map.

Thanks to this, we simplified things like getting the Javascript that we are going to use with in a server event.

It is just enough to initialize the GMap class with GMap_Id and add all the desired elements: controls, markers, infowindows, etc. The example is totally academic (click on the map):

<cc1:GMap ID="GMap1" runat="server" enableServerEvents="True" OnClick="GMap1_Click" />
protected string GMap1_Click(object s, GAjaxServerEventArgs e)
    GMap gmap = new GMap(;

    // GMarker and GInfoWindow
    GMarker marker = new GMarker(e.point);
    GInfoWindow window = new GInfoWindow(marker, "Cool!!", true);

    // Movement
    //gmap.Add(new GMove(1000, e.point + new GLatLng(25, 38)));
    //gmap.Add(new GMove(1000, e.point));

    // Controls
    gmap.Add(new GControl(GControl.extraBuilt.MarkCenter));
    gmap.Add(new GControl(GControl.preBuilt.LargeMapControl));
    gmap.Add(new GControl(GControl.preBuilt.MapTypeControl));

    // Polylines
    if (e.point !=
        List<GLatLng> points = new List<GLatLng>();

        gmap.Add(new GPolyline(points, Color.Yellow));

    // Maybe... anything? ;)
    gmap.enableHookMouseWheelToZoom = false;
    gmap.mapType = GMapType.GTypes.Satellite;

    return gmap.ToString();
Powered by Subgurim.NET