Hi everyone,
I have a GeoJSON layer that I have added to my webmap. I want to be able to click on the layer features and populate a sidepanel with elements based on the feature's properties (make request to db from app with Express query, populate sidepanel with returned array). How can I access the GeoJSON layer's properties for the feature that is being clicked? I looked at hitTest(), a MapView method. But surprised to see that GeoJSON is not a supported type of layer for the method.
Does anyone have any ideas on how I could achieve this? I'm able to access the properties on the popupTemplate fine. But I need more features than what the popupTemplate is giving me.
TLDR: Need to access GeoJSON properties from clicking element on map.
Thanks!
Solved! Go to Solution.
Looks like it's just an omission in the docs. hitTest works with GeoJSONLayer.
Looks like it's just an omission in the docs. hitTest works with GeoJSONLayer.
Thanks, Rene! Wish I'd given it a try before I switched my entire application to render Feature Layer instead.
Now I'm facing a problem where client-side graphics added to the feature layer cannot recognize click events for hitTest() or popupTemplate.
I believe this is a bug that was recognized in the API a couple of years ago, but still hasn't been fixed. See view.hitTest returning 0 results and PopupTemplate from Client Side Graphics Not Working