angular-ui / ui-leaflet

AngularJS directive to embed an interact with maps managed by Leaflet library
http://angular-ui.github.io/ui-leaflet
Other
314 stars 134 forks source link

Events not firing for geojson with onEachFeature #265

Open jozsi opened 8 years ago

jozsi commented 8 years ago

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.

mahmoudmy commented 8 years ago

You should call openPopup method to display it:

onEachFeature: function(feature, layer) {
  layer.bindPopup(formatMessage(row, dimensionsAndMetrics)).openPopup();
}
danielAlbuquerque commented 8 years ago

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