ui-leaflet icon indicating copy to clipboard operation
ui-leaflet copied to clipboard

Events not firing for geojson with onEachFeature

Open jozsi opened this issue 8 years ago • 2 comments

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.

jozsi avatar Jun 14 '16 14:06 jozsi

You should call openPopup method to display it:

onEachFeature: function(feature, layer) {
  layer.bindPopup(formatMessage(row, dimensionsAndMetrics)).openPopup();
}

mahmoudmy avatar Aug 31 '16 05:08 mahmoudmy

I'm trying to use .openPopup(), but i'm getting this error: Cannot read property 'openPopup' of undefined

danielAlbuquerque avatar Oct 13 '16 17:10 danielAlbuquerque