Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have geoserver serving shapefiles as a WMS into Leaflet.

I'd like to add interativity that shows a popup with WMS attributes in the Leaflet map when the user hovers over or clicks on a WMS feature.

I've seen the wax/leaflet interactivity, but is that possible with WMS and Leaflet?

share|improve this question

1 Answer 1

up vote 13 down vote accepted

You should try using WMS GetFeatureInfo. Here's an example with Leaflet made available Bryan McBride. The event used for triggering the GetFeatureInfo request is onclick.

share|improve this answer
    
Thanks that's just what I needed. –  zarbo Sep 14 '11 at 16:05
    
Now I'm working on formatting the GetFeatureInfo data with Geoserver Freemarker templates. Any thoughts on a Leaflet hover/mouseover interaction? –  zarbo Sep 14 '11 at 16:18
    
As shown in the example you should try changing the event passed to the onMapClick function: line 41 » map.addEventListener('click', onMapClick); I think you should take a look at the documentation page: leaflet.cloudmade.com/reference.html. Regarding the Geoserver freemarker templates I never used it, but it makes more sense to me to make a WFS GetFeature request asking for the response to be formatted in GeoJson instead of the WMS GetFeatureInfo. With that GeoJson object in the client side is far more easy to build a simple HTML markup to display the feature(s) data. –  Pedro Mendes Sep 14 '11 at 23:54
    
Sorry.. There's no way of making a GetFeature with Leaflet.. :/ Even though you could use the GeoJSON layer for the same effect (the feature's attributes are already accessible on the client). But that's I love OpenLayers =). –  Pedro Mendes Sep 15 '11 at 0:02
    
Hi Zabro,Did you manage to get this working? i want to implement same. would you mind sharing some code snippets? –  Pragnesh Patel May 15 at 14:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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