views:

348

answers:

1

Hi All,

I am trying to use the Google Map API- I've successfully managed to add an icon but when it is clicked nothing else happens...

This is my code:

function placeMarkerAtPoint(point)
{
    var marker = new GMarker(point,{icon: icon});

    GEvent.addListener(marker,"click",function() {

     marker.openInfoWindowHtml('here is some text');
    });

    map.addOverlay(marker);
}

When I run this in IE & click an Icon I see the not very useful javascript error: 'x' is null or not an object. I haven't even defined any variable called x ???

Thanks in advance for your your help

+2  A: 

Looks like you aren't instanciating an icon object (or not passing it into your placeMarkerAtPoint function).

Cannonade
Sorry I forgot to add that bit of code. I do this at the top of my js file like so:var icon = new GIcon();icon.image = "http://www.google.com/mapfiles/marker.png";icon.shadow = "http://www.google.com/mapfiles/shadow50.png";icon.iconSize = new GSize(20, 34);icon.shadowSize = new GSize(37, 34);icon.iconAnchor = new GPoint(10, 34);
samcooper11
Whops sorry just re-read your comment and now passed in the icon and its now working. Thank you!!
samcooper11
Glad to hear it :).
Cannonade