0

I try to identify features only from the wastepit layer. In this example I am adding two layers: wells and wastepit. I am only calling the identify function on the wastepit layer but I still get features if I press on a location for a well? Please see the codepen for live example. How can I do so I am only get the featureInfo from the wastepit layer? I dont understand why I in fact get feature from all (8) layers in the MapService?

    wells = L.esri.dynamicMapLayer({
            url: url,
            layers: [0]
          }).addTo(map);

pipe = L.esri.dynamicMapLayer({
                url: url,
                layers: [4]
              }).addTo(map);

wastepit = L.esri.dynamicMapLayer({
            url: url,
            layers: [5]
          }).addTo(map);

function getFeatureInfo(e) {
  wastepit.identify()
    .on(map)
    .at(e.latlng)
    .run(function(error, featureCollection){

https://codepen.io/GitMorin/pen/MLQvdM?editors=0010

  • 1
    Codepen example differs a great deal from the code above and your question. It's hard to quess then what you want to achieve. – TomazicM Feb 9 at 18:40
  • I am sorry about that, I was too slow to edit my question as I eventually found what the error was. The codepen now show a working example of what I tried to achieve to start – geogrow Feb 9 at 22:44
3

By default L.esri.IdentifyFeatures queries all the layers in the map service.

https://github.com/Esri/esri-leaflet/blob/v2.2.3/src/Tasks/IdentifyFeatures.js#L20

From the looks of your codepen, it appears you already found out that you can customize this behavior by supplying an alternative strategy and any combination of layers you want.

 .layers('all:5')

It's worth noting that dynamicMapLayer.bindPopup() passes through options set on the layer automatically.

It's also worth noting that its sub-optimal to add multiple individual dynamicMapLayers to the same map for each individual layer when you can ask the service to draw as many (or few) as you want all at once.

  • I did found it in the end, thank you for pointing it out – geogrow Feb 9 at 22:42

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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