Leaflet.label with geoJSON

3,052 views
Skip to first unread message

Michal Zimmermann

unread,
Feb 5, 2013, 8:10:01 AM2/5/13
to leafl...@googlegroups.com
Hi to all,
I would like to use Leaflet label from https://github.com/Leaflet/Leaflet.label with geoJSON polygons, but it gives me "TypeError: L.geoJson(...).bindLabel is not a function" when I do
L.geoJson(promenna, {
    style: function (feature) {
        return { color: '#0000FF', weight: 2, opacity: 1.0};
    },
    onEachFeature: function (feature, layer) {
        layer.bindPopup(feature.properties.nazev);
        // zoom a centrace mapy po přidání feature
        MAP.map.fitBounds(layer.getBounds());
    }
}).bindLabel('A sweet static label!', { noHide: true }).addTo(MAP.map);

Has anyone tried to use labels with geoJson?

Bryan McBride

unread,
Feb 5, 2013, 11:27:33 PM2/5/13
to leafl...@googlegroups.com
FWIW- I've had this issue with MultiLineString and MultiPolygon geometries. It seems to work fine on simple geometries though.
See https://github.com/Leaflet/Leaflet.label/issues/15

BRYAN

Michal Zimmermann

unread,
Feb 6, 2013, 7:00:21 AM2/6/13
to leafl...@googlegroups.com
Thank you for the link, I've used markers with invisible icons to display labels.


--
 
---
You received this message because you are subscribed to the Google Groups "Leaflet" group.
To unsubscribe from this group and stop receiving emails from it, send an email to leaflet-js+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Michal Zimmermann (zimmi) 
WWW: http://www.zimmi.cz
Reply all
Reply to author
Forward
0 new messages