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

FeatureLayer 'load' is sometimes called before individual features are available #545

Closed
jgravois opened this issue May 22, 2015 · 7 comments

Comments

@jgravois
Copy link
Contributor

i had an expectation that it would always be safe to write something like below before realizing that the 'load' event can be fired before we've stepped into createLayers()

fl.on('load', function(evt) {
  fl.eachFeature(function(layer) {
    // do amazing things (if there are features to loop through)
  });
});

it'd be pretty trivial to emit an entirely new event (Iike the JSAPI's 'update') in the second location i mentioned and it seems essential that we have a dependable hook for developers to do X with the features that are retrieved but i'm curious whether anyone else has any better ideas

my use case was writing a blog to show how to zoom to the extent of a collection which doesn't support calling bounds() on page load.

@patrickarlt
Copy link
Contributor

Fixed in 1e336d3

@jgravois
Copy link
Contributor Author

jgravois commented Jun 5, 2015

just did a quick check and the load event isn't firing at all in one of my simple applications. reopening so i can take a look.

@patrickarlt
Copy link
Contributor

@jgravois can you give me a reproduction of this issue? Its working properly in http://esri.github.io/esri-leaflet/examples/spatial-queries.html

@jgravois
Copy link
Contributor Author

jgravois commented Jul 1, 2015

good news. i can't reproduce the error anymore.

@jgravois jgravois closed this as completed Jul 1, 2015
@jgravois
Copy link
Contributor Author

jgravois commented Jul 1, 2015

nevermind. if i add this feature service to debug/sample.html on master, the load event isn't fired, even after all responses from the service have been received.

var fl = L.esri.featureLayer('http://services.arcgis.com/uCXeTVveQzP4IIcx/arcgis/rest/services/VaquitaProtection/FeatureServer/0').addTo(map);

fl.on('load', function(){
  console.log('please fire');
});

@jgravois jgravois reopened this Jul 1, 2015
@patrickarlt
Copy link
Contributor

Fixed this. Should be in the next release.

@jgravois
Copy link
Contributor Author

jgravois commented Jul 2, 2015

confirmed. awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants