Topic: Zoom up the map and keep the image existing

Hello,
I used the Online Maps offline. I found that I could zoom up the map even if there was not corresponding zoom level in the Resouces folder. Certainly, the map tile was not new image but the old which became fuzzy.
However, when I continued to zoom up the map to some degree, the image of the map tile disappeared.
Is there a way to keep the image always existing?

Re: Zoom up the map and keep the image existing

Hello.

In Online Maps v3.6:
Online Maps / Advanced / Count Parent Levels - 20.

In Online Maps v3.5 or earlier, this can only be done using API.
Points of interest:
OnlineMapsTileManager.OnTileLoaded
http://infinity-code.com/doxygen/online … f7070aa394
OnlineMapsTile.Block
http://infinity-code.com/doxygen/online … ba46a509b4

Kind Regards,
Infinity Code Team.

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

Re: Zoom up the map and keep the image existing

I am using Online Maps v3.5. Is it troublesome to achieve what I said by using API?

Re: Zoom up the map and keep the image existing

No, it's easy enough.

Kind Regards,
Infinity Code Team.

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

5 (edited by XiaWuchu 2019-10-11 11:29:07)

Re: Zoom up the map and keep the image existing

Alex Vertax wrote:

No, it's easy enough.

I checked the API, but had no idea how to do it yet. Could you give me more tips? Thanks a lot.

Re: Zoom up the map and keep the image existing

Something like:

using System.Collections.Generic;
using UnityEngine;

public class BlockTiles : MonoBehaviour
{
    public List<OnlineMapsTile> tiles;
    private OnlineMaps map;
    private object blocker;

    private void Start()
    {
        tiles = new List<OnlineMapsTile>();
        map = OnlineMaps.instance;
        map.OnUpdateLate += OnUpdateLate;
        blocker = new object();
    }

    private void OnUpdateLate()
    {
        double tlx, tly, brx, bry;
        map.GetTileCorners(out tlx, out tly, out brx, out bry);
        int max = 1 << map.zoom;
        if (tlx > brx) brx += max;

        int itlx = (int) tlx;
        int itly = (int) tly;
        int ibrx = (int) brx;
        int ibry = (int) bry;

        foreach (OnlineMapsTile tile in tiles) tile.Unblock(blocker);

        tiles.Clear();

        for (int z = map.zoom; z >= OnlineMaps.MINZOOM; z--)
        {
            for (int x = itlx; x <= ibrx; x++)
            {
                int cx = x;
                if (x > max) x -= max;

                for (int y = itly; y <= ibry; y++)
                {
                    OnlineMapsTile tile = OnlineMapsTile.GetTile(z, cx, y);
                    if (tile != null)
                    {
                        tile.Block(blocker);
                        tiles.Add(tile);
                    }
                }
            }

            max /= 2;
            itlx /= 2;
            itly /= 2;
            ibrx /= 2;
            ibry /= 2;
        }
    }
}
Kind Regards,
Infinity Code Team.

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

7 (edited by XiaWuchu 2019-10-13 09:01:10)

Re: Zoom up the map and keep the image existing

Thank you! It did work!
But it worked only for those tiles in the Game window at that moment. When I dragged the map, other tiles were still blank.
Is there a way to make whole tiles' image always exist even if there is no corresponding image when I drag or zoom the map?

Re: Zoom up the map and keep the image existing

This script only protects tiles from unloading, but does not load new tiles.

You have two ways:
1. Easy way - simple update to Online Maps v3.6.
2. Use OnlineMapsTileManager.StartDownloadTile to load the missing tiles in the example above. But you will need to implement this yourself.

Kind Regards,
Infinity Code Team.

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

Re: Zoom up the map and keep the image existing

Alex Vertax wrote:

This script only protects tiles from unloading, but does not load new tiles.

You have two ways:
1. Easy way - simple update to Online Maps v3.6.
2. Use OnlineMapsTileManager.StartDownloadTile to load the missing tiles in the example above. But you will need to implement this yourself.

OK, Thank you!

Re: Zoom up the map and keep the image existing

XiaWuchu wrote:
Alex Vertax wrote:

This script only protects tiles from unloading, but does not load new tiles.

You have two ways:
1. Easy way - simple update to Online Maps v3.6.
2. Use OnlineMapsTileManager.StartDownloadTile to load the missing tiles in the example above. But you will need to implement this yourself.

OK, Thank you!


Hello!
Finally, I decide to update. As you said, I found if I used Resources to load with the count parent level 20 the image would not disappear. However, I'd like to use StreamAssets to load tiles.

            WWW www = new WWW("file://" + Application.streamingAssetsPath + "/" + tile.resourcesPath + ".jpg");
            yield return www;
            Object tileTexture = www.texture;

In this case, the image would disappear when I continued to zoom up.
Is there a way to solve it?
THX!

Re: Zoom up the map and keep the image existing

Most likely the problem is that before "yield return" you did not mark that the tile is loading (tile.status = OnlineMapsTileStatus.loading), which gives you a huge memory leak and can cause any unexpected problems.

Kind Regards,
Infinity Code Team.

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