.Net ramblings
# Thursday, 02 January 2014
Google Maps API v3 control for Asp.Net with client side infowindows
I found this opensource google maps v3 control for asp.net, download from nuget:
tutorials etc from the author: http://www.reimers.dk/

the one thing i couldn't work out was how to handle client-side info-window (pop ups) when you click on a map marker.  this control has good support for server side clicks but that isn't what i wanted because it is too slow for the user.  here is the code i put together to get this to work, assuming you have a 'Map' control on your web page called Map1:

private void AddPoint(string desc, double latitude, double longitude, int width, int height, string iconPath, bool HtmlDescription)
    Marker m = new Marker(Guid.NewGuid());
    m.Draggable = false;
    m.Icon = new Icon(new Uri(iconPath, UriKind.RelativeOrAbsolute));
    LatLng point = new LatLng();
    point.Latitude = latitude;
    point.Longitude = longitude;
    m.Point = point;
    m.Icon.Size = new Size(width, height);
    if(!HtmlDescription)    // use tooltip "Title"
        m.Title = desc;
    m.Clickable = true;
    m.Description =  desc;

    m.ClientSideHandlers.OnClick = String.Format(@"var infowindow = new google.maps.InfoWindow();
            infowindow.open(reimers.map.Map1, reimers.map.Map1.overlays[{1}]);", desc.Replace("'", "\""), this.Map1.Overlays.Count);

Thursday, 02 January 2014 15:22:35 (GMT Standard Time, UTC+00:00)  #    Comments [0]  Asp.Net