I'm currently using mapbox with natural earth and geojson to populate a map with multipoygons and custom markers. Each of these has a set of properties and information that I need to display on click - Now i've got this working fine on the markers but when it comes to the polygons, I get an error saying cannot read properties of undefined.

I think the layer click even is handled differently for multipolygons, any idea how to handle this?

here's the jsfiddle http://jsfiddle.net/96bwsocx/


Maybe try var feature = e.target.feature instead of e.layer.feature?

e.layer would probably be the entire featureLayer, not the individual clicked feature. Hence it would not have the feature property defined, hence your error message when trying to access feature.properties.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.