Getting attribute table from geoserver layer in Leaflet

26 views
Skip to first unread message

dickson mbeya

unread,
Jun 14, 2022, 11:01:42 PMJun 14
to Leaflet
Hello,
 I have been trying to get attribute table of a geoserver layer in leaflet but I haven't been successful. Any one with an idea on how I can go about it. Specifically, I want the attribute table of the layer to popup when someone clicks on a polygon that is displayed in leaflet map.

Thanks.

Edwin Corrigan

unread,
Jun 19, 2022, 8:58:44 AMJun 19
to leafl...@googlegroups.com
Hello, 

Couple of things that might help:
- You can make a WFS getFeature request to Geoserver which can return a geojson format - https://docs.geoserver.org/stable/en/user/services/wfs/reference.html#wfs-getfeature
- L.geoJson can be used to render the returned geojson on the map - https://leafletjs.com/reference.html#geojson-l-geojson
onEachFeature can be passed as an option to L.geoJson, here is an example - https://codepen.io/dagmara223/pen/NdJJBJ
- You can access the properties object on each feature in your geoJson with something like feature.properties (I added a console.log from the above example):
image.png
- Adjust your html in layer.bindPopup, you can add third party UI libraries here too
- If you'd like the popup to appear on events such as click, dblclick, mouseover etc, you can replace the bindpopup function and render an L.popup inside the event handler function. Something like - layer.on(<event>, handler function), 

Best Regards, 

Edwin


Edwin Corrigan 

 

Tel: (353) 87 7552 666



--

---
You received this message because you are subscribed to the Google Groups "Leaflet" group.
To unsubscribe from this group and stop receiving emails from it, send an email to leaflet-js+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/leaflet-js/1b07f8ab-ba99-444f-afb6-9925891bcc2fn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages