[OpenLayers-Dev] defaultIcon: calculateOffset

Bart van den Eijnden (OSGIS) bartvde at osgis.nl
Mon Oct 29 08:10:39 EDT 2007

Hi list,

can anybody explain why the calculateOffset from the defaultIcon places the
icon on top of the point, and not in the center of the point?

OpenLayers.Marker.defaultIcon = function() {
    var url = OpenLayers.Util.getImagesLocation() + "marker.png";
    var size = new OpenLayers.Size(21, 25);
    var calculateOffset = function(size) {
                    return new OpenLayers.Pixel(-(size.w/2), -size.h);

    return new OpenLayers.Icon(url, size, null, calculateOffset);

Best regards,

Bart van den Eijnden
OSGIS, Open Source GIS

More information about the Dev mailing list