-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Add data, datastart and dataend events #1715
Comments
@jfirebaugh I think Map.load doesn't account for view changes requiring new tiles to be downloaded? @scothis A related issue I encountered today (copying from a #sneak-peek slack conversation):
Just tried that change here: master...anandthakker:fix-source-loaded. Seems to resolve my particular issue; lemme know if you want a pr, though maybe you'd rather solve this more systematically. |
^ Hmm, okay so my hack doesn't really resolve the problem after all: even after correcting I guess this is my 👍 for something like what @scothis proposed. |
@jfirebaugh looking for something like the |
Got it, thanks. I think maybe we should make |
Just wanted to +1 that I'm looking for something similar for when a geojson-source data url has loaded. Which I suppose would inherently trigger tile-loaded events. Just a slightly different case than a regular tile source. |
I'm in favor of building this and calling the event something other than Some strawman proposals:
|
|
What about updating the function signatures of
|
Leaflet uses |
+1. Related to #1715 (comment) I would expect |
I have successfully been able to detect when my features have loaded by watching the map.on("render", function() {
if(map.loaded()) {
map.featuresIn(...);
}
}); Ideally, an event at the exact time all layers on the map are ready is better, rather than checking all the |
+1 @timjcook |
+1 @timjcook that worked for use case as well, adding a loading bar while source.setData() is executing. |
I'm thinking about resolving this issue with
This parallels the structure of
💭 @scothis? |
@lucaswoj works for me |
👍 I like the symmetry there. |
+1, I would like to implement a loading spinner on my map when it is fetching tiles or waiting for geojson ajax calls to return. I would love it if there was a simple event that would fire when all layers are fully rendered. |
is it possible to load different data layers dependent and a time of day month. ex. broadcast listener of system time |
@LDF913 Due to the large volume of issues we get and the relatively small size of our team, we are unable to provide support here on GitHub. I recommend asking this question on Stack Overflow. |
A reliable dataend event would be great, using render and map.loaded() occasionally doesn't work, on the final render event fire the map is still not loaded. Can't reliably reproduce though. |
I was able to fairly reliably check if ajax-type data was loaded via: map.on('data', function (data) {
if (data.dataType === 'source' && data.isSourceLoaded) {
console.log('data loaded', data)
// stop listening to map.on('data'), if applicable
}
}) The |
@joehand: thanks for |
@jucor what I've done is to just start a timer on sourcedata event that checks map.loaded() every half a second and then removes the loading wheel. Not had a problem with this approach |
@jdeboer-geoplan Nice workaround, thanks! |
Following this thread as my app also needs this. |
It's amazing that this issue is 2 years old. This feature is table stakes. |
is this work in progress ? |
Is this related to #3964 I'd like to see it as on |
i don't understand how for example get the event tile.remove. Was it removed, is there a documentation about all events? i use this.map.on('data', event... |
Hi @anandthakker, I am facing the same issue of "sourcedata" callback is not calling if one of the tiles in viewport fails to load, even the map.loaded() is not true. I have high dependency on this, I set the state of feature on this basis(querySourceFeatures). I am stuck in this, if there is an alternative to this. Please suggest. Like if we can abort/unload/remove that particular tile and make e.isSourceLoaded to true in callback
Please give me some suggestions on this. |
I appreciate jdeboer-geoplan's suggestion; he or she could have been a little more explicit. I think a recursive timeout is the answer. This seems to work (most of the time) for me. I'm not sure if areTilesLoaded() helps or not. Also, isStyleLoaded could be added.
|
Edit : I went for the My use case : I want to use It's quite similar to the airport example in the documentation. This issue was avoided by displaying a message If I understand it correctly, Seeing how often the // when a new layer is added
layers$.subscribe((layers) => {
this.map.on("render", checkRenderedFeatures);
setTimeout(() => this.map.off("render", checkRenderedFeatures), 2000);
}); This way I don't like it one bit but hopefuly |
Yes, idle provided a solution for me too. I don't know how many years the idle event has been available but it should have been mentioned a long time ago for this issue. Like anyone else I guess I could have said something earlier. |
There are events for when individual tiles load, but it's difficult to know when all the tiles for a source have finished loaded. Essentially, I'd like an API to know if tiles requests are in flight, or if the all the data I would expect to view for a given view is already loaded. Firing an event when the state transitions would also be helpful.
Knowing when a source is fully loaded is useful for smoothly transitioning between different overlay sources without a flash as tiles load.
As a quick sketch, I'd imaging something like:
The text was updated successfully, but these errors were encountered: