ui-leaflet
ui-leaflet copied to clipboard
Events not firing for geojson with onEachFeature
I want to display a popup
(not label
) on my GeoJSON, so I am adding this:
onEachFeature: function(feature, layer) {
layer.bindPopup(formatMessage(row, dimensionsAndMetrics));
}
But looking at _hookUpEvents in the geojson directive, the bindEvents
method is only called if there is not onEachFeature
set.
Is this a bug or a feature? In my scenario it's definately a bug.
You should call openPopup
method to display it:
onEachFeature: function(feature, layer) {
layer.bindPopup(formatMessage(row, dimensionsAndMetrics)).openPopup();
}
I'm trying to use .openPopup(), but i'm getting this error: Cannot read property 'openPopup' of undefined