question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Request for `tileLayer.whenLoaded` function

See original GitHub issue

Is your feature request related to a problem? Please describe. My use case:

  1. Start flyTo programmatically to another location in the map
  2. Wait for the tiles in the new location to be loaded, then do X.

Currently I can only rely on tileLayer.on("load", function(){}). However, when the new location is already loaded in the beginning (e.g., when the new location is nearby), there is nothing I can use to inform step 2 that X can now be done (“load” event won’t fire since the map is already loaded).

I cannot just rely on “moveend” or “zoomend”, since by the time we reach the new location, the new location might not finish loading yet.

Describe the solution you’d like Just like map.whenReady function, which fires immediately when the map is set, I would like to have tileLayer.whenLoaded function, which fires immediately if the visible tile layer is already loaded.

Describe alternatives you’ve considered

  1. Putting X only on “moveend” or “zoomend” doesn’t guarantee that the visible tile is loaded.
  2. Putting X only on tileLayer.on("load") doesn’t guarantee that it will fire.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
johnd0ecommented, Mar 17, 2021

Is there any advantage of doing this using lower level checks (this._loading) versus a higher-level one (isLoading())?

There is no real advantage. As a rule we use private properties (_loading) in Leaflet’s own code, but in client code (or plugins) public method is preferable. Reason: private property can be changed in future version without notification, why public one is part of API, and thus more stable.

0reactions
justhalfcommented, Mar 17, 2021

Thanks for the response!

This seems similar to the solution we found here: https://stackoverflow.com/questions/66382098/does-there-exist-a-function-to-tell-if-the-current-tilelayer-is-already-load

Is there any advantage of doing this using lower level checks (this._loading) versus a higher-level one (isLoading())?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Does there exist a function to tell if the current tileLayer is ...
What I would like to have: map.on("moveend zoomend", function(){ baseLayer.whenLoaded(function(){ // do something }); }); map.flyTo(latlng);.
Read more >
Documentation - a JavaScript library for interactive maps
TileLayer. Used to load and display tile layers on the map. Note that most tile servers require attribution, which you can set under...
Read more >
Solved: Cannot access items array property of MapView.allL...
Solved: See below: require ([ "esri/Map" , "esri/views/MapView" ], function ( Map , MapView ) { var map = new Map ({ basemap...
Read more >
Intro to layers | ArcGIS Maps SDK for JavaScript 4.25
To do this, you must require the esri/layers/TileLayer module and specify the url ... A layer is a promise that resolves when loaded,...
Read more >
API Resource: Using count() with whenLoaded() - Laracasts
class ShopResource extends \Illuminate\Http\Resources\Json\Resource { public function toArray($request) { $resource = [ 'id' => $this->id, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found