Using the Leaflet API I am adding a WMS layer through the L.tilelayer.WMS feature. This feature includes only a certain amount of options such as 'layers','crs','style' etc.

Through the Leaflet documentation I figured that the L.GeoJSON feature includes the 'onEachFeature' option. I would like to use this 'onEachFeature'' option within the WMS layer.

What would be a solution to apply an 'onEachFeature' option within a Leaflet WMS TileLayer?

  • 1
    A tile layer is just a bunch of images, organized to act like a map in your browser, so there are no features to iterate over. Sometimes you can get tiles for the map, and geojson for your features for fast, in-browser interactivity. Or, maybe you could do something with WFS (not WMS) from your server, but that is another question. – toms Jun 4 '15 at 20:40
  • If you're limited to a WMS, then you will need to look at doing a GetFeatureInfo request on the WMS layer to get at any underlying feature information. This will require that the WMS layers are queryable. – nmtoken Sep 22 '16 at 12:18

You should take a look at this plugin : https://github.com/heigeo/leaflet.wms

It allows you to get info on a popup for each 'feature' of a wms layer.

  • *if the WMS supports GetFeatureInfo requests. – Richard Law Oct 23 '16 at 4:05

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.