views:

27

answers:

2

Hello! I have some problems combining a custom marker icon with my infoWindow.

Here is my js code:

    var micon = new GIcon();
    micon.image = "/path/to/my/icon.png";
    micon.iconSize = new GSize(25, 17);
    micon.iconAnchor = new GPoint(25, 17);

    markerOptions = {
        icon:micon
    }

    var point = new GLatLng(48.092757,11.645508);
    var marker = new GMarker(point, markerOptions)
    map2.addOverlay(marker);

This is working. I get my marker at the right position with my custom icon. Now I want to add an infowindow to my marker, so I added

    GEvent.addListener(marker, 'click', function() {
        marker.openInfoWindowHtml('Some text');
    });

right after my var marker = new GMarker(point, markerOptions)

Now, on clicking my custom icon, I get an error (at firebug) called:

a is undefined

When removing my markerOptions at new Marker(), it works (but without my custom icon)

    var marker = new GMarker(point, markerOptions);
    GEvent.addListener(marker, 'click', function() {
        marker.openInfoWindowHtml('Some text');
    });

    map2.addOverlay(marker);

to

    var marker = new GMarker(point);
    GEvent.addListener(marker, 'click', function() {
        marker.openInfoWindowHtml('Some text');
    });

    map2.addOverlay(marker);

What's wrong with my code?

A: 

have you tried,

var marker = new GMarker(point, micon)
Reigel
same error ( `a is undefined[Break on this error] window.__gjsload_maps2_api__=function(...a,b,c,d,f){cd(dd).require(a,b,c,d,f)}` )
Newbie
i don't know but I think Gmarker has only one parameter in its constructor, http://www.mapmap.org/googlemaps/mock/js_docs_out/GMarker.html#GMarker()
Reigel
A: 

I solved my problem! I had to add micon.infoWindowAnchor = new GPoint(25, 17); to my GIcon().

Newbie
well, that's good! :)
Reigel