Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setWhere callback is not called #875

Closed
mepdr opened this issue Oct 25, 2016 · 6 comments · Fixed by #1211
Closed

setWhere callback is not called #875

mepdr opened this issue Oct 25, 2016 · 6 comments · Fixed by #1211

Comments

@mepdr
Copy link

mepdr commented Oct 25, 2016

Changing the where condition on a newly created layer doesn't let the callback to be executed.

var layer = L.esri.featureLayer({
    url: "link",
    where: "1=1",
});
layer.addTo(map);
layer.setWhere("1=2", function(){
    console.log("callback called");
});

The callback is correctly executed if the setWhere is executed after a few seconds.

@jgravois
Copy link
Contributor

i can't reproduce the error you describe: http://jsbin.com/yejeki/edit?html,output

that said, we definitely could do a better job of cancelling pending requests and clearing associated graphics to ensure that the map immediately reflects the latest filter in situations when the layer is in the process of fetching features when setWhere() is called.

@mepdr
Copy link
Author

mepdr commented Oct 26, 2016

I guess the issue is more general.
In your example, the callback is called but the map reflects the first where clause "1=1" (all parks) and not the second one "1=2" (no parks at all). As a result all parks are shown.
By wrapping the setWhere in a setTimeout the result is odd.
With an high values (ex: 1000ms) no parks are shown.
Decreasing the timeout value leads to a map in which only a subset of the parks are shown.

  setTimeout(function(){
    parks.setWhere("1=2", function (e) {
      console.log('done');
    });  
  }, 300);

esri_leaflet_error
Tested on chrome 54

@mepdr
Copy link
Author

mepdr commented Oct 26, 2016

@jgravois seems that the issue with the callback not fired is related to the use of esri leaflet renderers.

@mepdr
Copy link
Author

mepdr commented Nov 2, 2016

Since the initial issue seems more related to esri-leaflet-renders I've opened an issue there Esri/esri-leaflet-renderers#132.

An other issue raised is related to the fact that not all features are removed from the layer after setWhere is called (as shown by the image posted in #875 (comment)). See also in http://jsbin.com/yejeki/edit?html,output, the correct result should be to hide all features.

@jwasilgeo
Copy link
Contributor

jwasilgeo commented Dec 11, 2018

I've been able to see this happening, too, at esri-leaflet v2.2.3, described more or less the by the title of #780. One way to repro (and thanks for the idea, @gavinr) is to slow down network traffic speeds with the browser dev tools.

  1. Navigate to this sample page: https://esri.github.io/esri-leaflet/examples/querying-feature-layers-1.html
  2. Dev tools --> network tab --> throttle to a slower speed
  3. Refresh the sample page
  4. Choose a new bus direction where clause filter as soon as you can and before the feature layer is fully loaded and ready
  5. Although it may be hard to see with point icon markers, the state of the layer is a bit off and you may see both all (1=1) and the filtered subset of features

@jwasilgeo
Copy link
Contributor

I think this had to do with network request race conditions prior to v2.4.0. Let's be sure to look at this issue while investigating #1196.

patrickarlt added a commit that referenced this issue Jul 8, 2020
jgravois pushed a commit to jgravois/esri-leaflet that referenced this issue Apr 23, 2022
jgravois pushed a commit to jgravois/esri-leaflet that referenced this issue Apr 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants