tags:

views:

166

answers:

1

Hiya,

As far as I can tell, this code is fine, and should display some custom icons with popup HTML windows. But the popups aren't working! Can anyone point out what I'm doing wrong? I can't seem to debug it myself.

Thanks!

function initialize() {
    if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
        map.setCenter(new GLatLng(51.410416, -0.293884), 15);
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
        var i_parking = new GIcon();
            i_parking.image = "http://google-maps-icons.googlecode.com/files/parking.png";
            i_parking.iconSize = new GSize(32, 37);
            i_parking.iconAnchor = new GPoint(16, 37);
            icon_parking = { icon:i_parking };
        var marker_office = new GMarker(new GLatLng(51.410416,-0.293884));
        var marker_parking1 = new GMarker((new GLatLng(51.410178,-0.292000)),icon_parking);
        var marker_parking2 = new GMarker((new GLatLng(51.410152,-0.298948)),icon_parking);         
        GEvent.addListener(marker_parking1, 'click', function() {  
            marker_parking1.openInfoWindowHtml('<strong>On Street Parking</strong><br>Church Road - 40p per hour');  
        });
        GEvent.addListener(marker_parking2, 'click', function() {  
            marker_parking2.openInfoWindowHtml('<strong>Multi Storey - Fairfield</strong><br>Upper Car Park - 90p per half hour<br>Lower Car Park - £1.20 per hour');  
        });         
        map.addOverlay(marker_office);
        map.addOverlay(marker_parking1);
        map.addOverlay(marker_parking2);
    }
}
+2  A: 

The problem is that you need to set the infoWindowAnchor on your GIcon object. You can find a working example here.

Cannonade
Great stuff - thanks a lot! That makes sense when you think about it...
hfidgen