flutter_map icon indicating copy to clipboard operation
flutter_map copied to clipboard

[FEATURE] Add Option To Preload Tiles Around Current Area

Open JaffaKetchup opened this issue 3 years ago • 1 comments

What do you want implemented?

A property that can take a number of tiles in each direction outside of the current viewport to preload and render for smoother appearance. Additionally (if possible), a method to preload and render a list of tile coordinates or URLs.

What other alternatives are available?

No response

Can you provide any other information?

Related to #1336.

Platforms Affected

Android, iOS, Web, Windows, MacOS, Linux

Severity

Obtrusive: No workarounds are available, and this is essential to me

Requirements

  • [X] I agree to follow this project's Code of Conduct
  • [X] I am using the latest stable version of this package
  • [X] I have checked for similar feature requests which may be duplicates

JaffaKetchup avatar Aug 11 '22 18:08 JaffaKetchup

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Oct 01 '22 02:10 github-actions[bot]

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Nov 01 '22 02:11 github-actions[bot]

Hello ! any updates?

SalsabeelaHasan avatar Nov 10 '22 06:11 SalsabeelaHasan

Not yet, we will wait on a greater rewrite first.

JaffaKetchup avatar Nov 10 '22 07:11 JaffaKetchup

All the best. if there is clear timeline, it would be great. thank you!

SalsabeelaHasan avatar Nov 10 '22 07:11 SalsabeelaHasan

Unfortunately no timeline at the moment. We maintain this in our spare time, and at the moment, we are quite busy.

If your business/employer is waiting for this, it may help to offer a bounty to @MooNag (probably best to contact him via Discord), as he was the one originally suggesting the rewrite - but I'm not him so I can't say. Of course, absolutely 0 requirement/pressure to do this (we are open source after all), but it has worked in the past to fix a rather specific bug that someone needed. At the moment, I'm far too busy to do any major work here - I've got exams approaching.

JaffaKetchup avatar Nov 10 '22 08:11 JaffaKetchup

it shouldn't be too fiddly I would have thought if someone needs it to have a bash and do a PR. Pass in a param for number of extra tiles in each direction. Then subtract this from the min extent of the tile range, and add to the max in both x,y directions. Eg around line 605 of

// create a queue of coordinates to load tiles from
    for (var j = tileRange.min.y; j <= tileRange.max.y; j++) {
      for (var i = tileRange.min.x; i <= tileRange.max.x; i++) {

Add a test that the values aren't below 0 or above the max tile extent for that xoom.

ibrierley avatar Nov 10 '22 08:11 ibrierley

@ibrierley I've tried this before and it didn't work - can't remember why though. Maybe I was just trying to do it externally through a tile provider.

JaffaKetchup avatar Nov 10 '22 15:11 JaffaKetchup

Ok, I'm away atm, but will see if I can get time to take a peek when back if no one else wants a bash before that.

ibrierley avatar Nov 10 '22 17:11 ibrierley

Thank you all, waiting for your improvements.

SalsabeelaHasan avatar Nov 13 '22 00:11 SalsabeelaHasan

@ibrierley @JaffaKetchup Hi friends, long time no see :) Can this preloading also be used in this use-case: Assume that before the FlutterMap is created and rendered, we know which center latlng and zoom level to display. And when the first frame of the map is rendered, we will see the map tiles immediately without waiting for them from the network. So maybe the MapController object can do the preloading behind the scenes since we pass it the viewport info. And as devs, we can manage when to create the controller (most probably once we know the users location, instead of when the user presses the map page tab) Do you think this is a valid use-case?

aytunch avatar Nov 30 '22 23:11 aytunch

@ibrierley @JaffaKetchup Hi friends, long time no see :) Can this preloading also be used in this use-case: Assume that before the FlutterMap is created and rendered, we know which center latlng and zoom level to display. And when the first frame of the map is rendered, we will see the map tiles immediately without waiting for them from the network. So maybe the MapController object can do the preloading behind the scenes since we pass it the viewport info. And as devs, we can manage when to create the controller (most probably once we know the users location, instead of when the user presses the map page tab) Do you think this is a valid use-case?

The suggested PR wouldn't add that ability. I feel like that's a separate issue/solution ? Maybe that just needs an Offstate widget until a certain timeframe or something, but I'm not sure there's currently a way to know when all the tiles are loaded (if I'm reading right, it feels like that maybe the key part, but what about if one tile doesn't get loaded for some reason... ?). So maybe it needs a new issue raised for discussion.

ibrierley avatar Dec 01 '22 07:12 ibrierley