Leaflet: Popup offset

Created on 18 Jun 2012  路  5Comments  路  Source: Leaflet/Leaflet

I want to modified the offset of a CircleMarker's popup (I use geojson datas)

var geojsonLayer = new L.GeoJSON(null, {
    pointToLayer: function (latlng){
        return new L.CircleMarker(latlng, {
            radius: 8,
            fillColor: "#ff7800",
            color: "#000",
            weight: 1,
            opacity: 1,
            fillOpacity: 0.8
        });
    }
});
geojsonLayer.on("featureparse", function (e) {
    var popupContent = e.properties.popupContent;
    e.layer.bindPopup(popupContent);
});
map.addLayer(geojsonLayer);

I didn't find where to add the offset : I tried in bindPopup (after popupContent) but it's not working.

e.layer.bindPopup(popupContent,(10,10));

Someone can help me?

Most helpful comment

Try this:

e.layer.bindPopup(popupContent, {offset: new L.Point(10, 10)})

All 5 comments

Try this:

e.layer.bindPopup(popupContent, {offset: new L.Point(10, 10)})

Thanks a lot!

Nice! Thanks!

IS there a way to dynamically reset the offset? I am trying a variable for offset that is set on a map zoom, but it doesn't seem to work..thanks!

@mourner You just saved my day!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

onethread picture onethread  路  3Comments

ttback picture ttback  路  4Comments

viswaug picture viswaug  路  4Comments

arminghm picture arminghm  路  3Comments

piehei picture piehei  路  3Comments