[OpenLayers-Users] Bug with custom markers?

Cranio cranio at quipo.it
Fri Jan 25 06:07:48 EST 2008


Hi all.

I've created a map with some markers on it. By clicking on the marker, a
popup is shown with some ajax-retrieved data. And all goes fine.

Strange thing though: if i don't specify any custom icon and go with the
default one, all is fine. When I try to insert a custom PNG as icon,
suddenly the marker doesn't fire any click event.

Is it a bug or what?

------------------------------

For further info, here's the JS function that creates the icon and the one
for the marker:

[...]

var size = new OpenLayers.Size(26,26);
var offset = new OpenLayers.Pixel(-(size.w/2),-(size.h/2));
var icon = new OpenLayers.Icon('/path-to-icons/1.png',size,offset);
aM(icon,lon,lat,0);

[...]

function aM(icon,lon,lat,id)
{
    var ll = gmap.forwardMercator(lon,lat);
    feature = new OpenLayers.Feature(gmap,ll);
    var marker = feature.createMarker();
    marker.icon=icon; // <--- I HAD TO DO THIS WAY CUZ I USED
feature.createMarker ... MAYBE I SHOULDN'T?
    markers.addMarker(marker);
    marker.id=id;
    marker.events.register("mousedown", marker, mousedown);
}
-- 
View this message in context: http://www.nabble.com/Bug-with-custom-markers--tp15085502p15085502.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list