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

2
  • 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
    Commented Feb 9, 2019 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
    Commented Feb 9, 2019 at 22:44

1 Answer 1

4

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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