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

Option for queryRenderedFeatures: execute only when map.loaded() #2796

Closed
peterqliu opened this issue Jun 28, 2016 · 3 comments
Closed

Option for queryRenderedFeatures: execute only when map.loaded() #2796

peterqliu opened this issue Jun 28, 2016 · 3 comments

Comments

@peterqliu
Copy link
Contributor

Offshoot of #2471 discussion:

When I call queryRenderedFeatures(), I assume the results come from a fully loaded map, with zoom/center defined as the map's state at the time I invoked it. Currently, I can achieve this with:

map.on('render', function() {
  if (map.loaded()){
    map.queryRenderedFeatures(...);
    map.off('render');
  }
})

I think it's a fair assumption that no one wants to run .qRT on a partially loaded map, so it would be nice for the method to check for map.loaded() internally before doing the query. Either by default, or via some parameter like map.queryRenderedFeatures({onDataend:true});

@jfirebaugh
Copy link
Contributor

What should it return if map.loaded() is false?

@peterqliu
Copy link
Contributor Author

What should it return if map.loaded() is false?

I should say that this option would turn .qRT into an async method. It would not return anything until that evaluates to true.

@jfirebaugh
Copy link
Contributor

We had multiple design discussions regarding whether .qRT should be synchronous or asynchronous, and the conclusion was that a sync API was preferable. I don't think we want to re-litigate that, and I don't think it would be good API design to make it synchronous by default but asynchronous if you pass a specific option. Please continue to use the on('render') pattern where needed.

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