Topic: Cached map area download problem

Hello. I have a problem with showing cached areas at the map. The problem is that i implemented my own download engine to resources and when i switch off mobile data or set resources source at editor, zoom levels just dont change when i increase them.

My steps:

1) download some area : image attach left
2) zoom in in this area : image attach right

What i've tried to do:
1) Save in Resources/OnlineMapsTiles/zoom/x/y
2) Save in Resources/Tiles/zoom/x/y
3) Save in Resources/OnlineMapsCache/provider/x/y

The behaviour is the same. Also i tried to use https://forum.infinity-code.com/viewtop … 4612#p4612 this script and nothing changed. What can be the problem?
Also i debuged "TryLoadFromFileCache" method and it does not called when i increase zoom and dont get why, if new tiles should be checked when they are load in "InitTile" in Updating Buffer.

Post's attachments

Attachment icon 6NG1R2M.png 362.36 kb, 64 downloads since 2020-11-10 

Re: Cached map area download problem

Hello.

Where do you save the data in the script you implemented? To Resources folder?
You don't have write access to Resources after build.
Typically, Application.persistentDataPath folder is used for these purposes.
https://docs.unity3d.com/ScriptReferenc … aPath.html

TileDownloader stores tiles in persistentDataPath.

The cache is also not stored in Resources, and the file cache tries to load only the tiles that are present in the atlas.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Cached map area download problem

yes, i save in application data path and permissions are ok, the path is like:
C:\Users\User\AppData\LocalLow\companyName\appName\OnlineMapsCache\TileCache\osm\mapnik\le\en\17\76550
for example, and map does not switch to 17 zoom at all, while i ve downloaded this area

Re: Cached map area download problem

Intercept requests to load tiles this way ...
https://infinity-code.com/atlas/online- … ample.html
... and read the tiles from your path.

Tip: do not use the cache folder for your tiles, because this will create two problems:
1. The cache will not load and/or delete these files because they are not in the atlas.
2. If you delete them yourself, then how do you know if this file is not in the atlas, which can create dead records in the atlas.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Cached map area download problem

The problem is that i want to store files at cache folder because i want to save different providers for offline usage, also can i manually add downloaded textures to atlas?
Or i should manually resolve the cases when i have inet conection to use cache normally and no inet conection and use my own folders?

Re: Cached map area download problem

No, you cannot add items to the tile cache or atlas. The cache is simply not designed for this.

No, you don't have to resolve it manually.

How tile loading works:
1. If a tile is in the cache, it is loaded from the cache.
2. If someone has subscribed to OnStartDownloadTile, this event is called, where you can load the tile yourself or do some action, and continue downloading using the built-in downloader. If you loaded a tile yourself, then it is not cached.
3. If the settings indicate that a tile should be loaded from Resources or Streaming Assets, the tile is searched for in these folders.
4. The tile is loaded from the Internet.

So you need to subscribe to OnStartDownloadTile, and download the tile from your folder.

How to get the provider id:

private void OnStartDownloadTile(OnlineMapsTile tile)
{
    // ...
    
    OnlineMapsRasterTile rTile = tile as OnlineMapsRasterTile;
    string provider_id = rTile.mapType.provider.id;

    // ...
}
Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Cached map area download problem

ty for your help, it working great now, but the problem now is that there are grey tiles on reload, but there it was working better before loading from my source, how to make smooth reload tiles on zoom?

Re: Cached map area download problem

Please show your code where you load the tiles.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Cached map area download problem

sure, https://pastebin.com/56JHhDue

Re: Cached map area download problem

I checked your code and it works correctly on my side.
Video:
https://www.dropbox.com/s/huvsmu1absm7v … 3.mp4?dl=0

A couple of things about the video:
1. I disabled the cache and commented out part of the script so that tiles are loaded only from your path.
2. I set Count Parent Tiles to 0 so that parent tiles do not affect the view of the map, and tiles are unloaded when zoom in, and loaded again when zoom out.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

11 (edited by wththd 2020-11-12 10:54:11)

Re: Cached map area download problem

i mean if i disable my script - tiles load without being gray like this
https://i.imgur.com/HxSrPy4.gif
when i activate my script, there is grey tiles appear after zoom in/out
like this
https://i.imgur.com/W3hMtJq.gif

Re: Cached map area download problem

I just checked the map in all modes, and for me it only happens when Count Parent Levels - 0, which is logical, because the map unloads all previous zoom levels when the zoom changes.
Please show screenshots of all of your map components (including Advanced and Troubleshooting sections of the map component).

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

13 (edited by wththd 2020-11-12 12:28:22)

Re: Cached map area download problem

Yes, sorry, it was my fault, because i set parent levels to 0. Thank you very much for your help. Last question: i tried to use your example inertia but it is not smooth enough, even if i tried to use smoothdamp on speed and increasing max samples  is there any suggestions to improve example inertia?

Re: Cached map area download problem

Please clarify what you mean by "is not smooth enough"?
I just tested this on my side and it is very smooth. Video:
https://www.dropbox.com/s/1fk6jetkkzjvz … 4.mp4?dl=0
Unfortunately, the video doesn't quite convey the smoothness I have on the device.
But believe me, there are no freezes or lags here.
Maybe I'm just looking in the wrong direction.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Cached map area download problem

The map moves jumpy on slow speed, im now using default inertia script with default 0.9 value
https://i.imgur.com/eH79eci.gif

Re: Cached map area download problem

Unfortunately I don't see a problem here.
I compared the inertia in Online Maps and the inertia in Google Maps, and I think it looks very similar.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.