1 (edited by chema 2019-11-13 13:21:50)

Topic: Change Custom Provider URL at runtime and Slow loading of map tiles

Hello,

I am using Online Maps 3.6.0.2, Unity 2019.2.3 and Google Maps API as provider.

I need to change the Custom Provider URL at runtime to change the style of my map. After change it, I clear the cache (OnlineMapsCache.instance.ClearAllCaches()) and redraw the map (OnlineMaps.instance.Redraw()) but it does not work, how can I do this properly? However, if I zoom-in or zoom-out it works.

Also I have an issue with the visual loading effect of the map tiles, it is very slow on PC and even more on mobile. You can see it here: https://imgur.com/a/1HQqZXd. Any advice?

Greetings!

Re: Change Custom Provider URL at runtime and Slow loading of map tiles

Hello.

If you try to change the custom url at runtime, you will have many problems, not only with the cache.
The right way here is to create your own provider and map types.
Example:
http://infinity-code.com/atlas/online-m … ample.html

Kind Regards,
Infinity Code Team.

Do not know the best way to thank the developer? Rate the asset in Asset Store!

Re: Change Custom Provider URL at runtime and Slow loading of map tiles

Thanks! Now it works like a charm, I can change the style without problems! Although the other problem persists.

Re: Change Custom Provider URL at runtime and Slow loading of map tiles

1. Try to increase the maximum number of simultaneous downloads (OnlineMapsTileManager.maxTileDownloads).
2. Check the tile load time.
Perhaps the problem is that the server is too far (in another country) or has a long response time (for example, this is your own WMS).
3. Try preloading tiles for a larger area to minimize this effect.

Kind Regards,
Infinity Code Team.

Do not know the best way to thank the developer? Rate the asset in Asset Store!

Re: Change Custom Provider URL at runtime and Slow loading of map tiles

Hello,

1. This worked for me on PC, but it does not on mobile.
3. Can you give me a tip for this? How can I do it?

Greetings!

Re: Change Custom Provider URL at runtime and Slow loading of map tiles

I looked at your GIF again, and your tiles do not match for different zoom levels.
Please send your url, I will check why this happens.

P.S. What is your server response time when downloading tiles to PC and mobile?

Kind Regards,
Infinity Code Team.

Do not know the best way to thank the developer? Rate the asset in Asset Store!

Re: Change Custom Provider URL at runtime and Slow loading of map tiles

My url is:

https://maps.googleapis.com/maps/vt?pb= … Om9mZg!4e0

For the response time I have written two lines within the StartDownloadTileAsync method (OnlineMapsTileManager.cs):

        if (loadOnline)
        {

            float startTime = Time.realtimeSinceStartup;

            [...]

            Debug.Log((Time.realtimeSinceStartup - startTime) * 1000);
        }

I do not know it is the server response time, but on PC the values are between 0.09 and 0.12 and on mobile the values are between 0.3 and 0.8 (or more).

Re: Change Custom Provider URL at runtime and Slow loading of map tiles

I tested your url on PC (hi-end) and Android (low-end).
I have similar download times for tiles.
But I do not have what problem as I see in your GIF.
https://i.ibb.co/tMY8Th8/img1.png
In the image, I marked with arrows the places where the border between the tiles is visible.
Most likely, this is because these are wrong tiles.
But the main question is, why are the wrong tiles here?!
I scrolled and zoomed the map a lot, but did not see anything like it.

I tested all map modes without using a cache.
My apk is attached.
In this apk do you have a problem like in GIF?

Post's attachments

Attachment icon Test.apk 45.93 mb, 1 downloads since 2019-12-03 

Kind Regards,
Infinity Code Team.

Do not know the best way to thank the developer? Rate the asset in Asset Store!

9 (edited by chema 2019-12-04 07:33:03)

Re: Change Custom Provider URL at runtime and Slow loading of map tiles

Your apk works perfectly! Can I see your source code?
Which version of Online Maps are you using? I will try to do the same in my project and see if it works properly.

Re: Change Custom Provider URL at runtime and Slow loading of map tiles

I use the latest version of the asset (3.6.3) with default settings.
Here's a video:
https://www.dropbox.com/s/jmfge80qpgbgt … 1.mp4?dl=0

P.S. Create Browser is another feature of our asset.
You can open Map Wizard using Hierarchy / Create.

Kind Regards,
Infinity Code Team.

Do not know the best way to thank the developer? Rate the asset in Asset Store!

Re: Change Custom Provider URL at runtime and Slow loading of map tiles

Thank you so much. The problem was the tile set shader, with the default shader works!

Although now the map is darker, I will see what I can do.

Re: Change Custom Provider URL at runtime and Slow loading of map tiles

I tested with the Tileset shader, and also could not reproduce the problem.
Most likely the problem is in something else.

To prevent the map from being too dark, adjust the light in the scene.
Or remove all the lights in the scene and set up Ambient Color (Window / Rendering / Lighting Settings / Environment Lighting / Source - Color, Ambient Color - White).

Kind Regards,
Infinity Code Team.

Do not know the best way to thank the developer? Rate the asset in Asset Store!

Re: Change Custom Provider URL at runtime and Slow loading of map tiles

Test this shader to reproduce the problem:

Shader "Unlit/MapShader"
{
    Properties
    {
        // we have removed support for texture tiling/offset,
        // so make them not be displayed in material inspector
        [NoScaleOffset] _MainTex ("Texture", 2D) = "white" {}
    }
    SubShader
    {
        Pass
        {
            CGPROGRAM
            // use "vert" function as the vertex shader
            #pragma vertex vert
            // use "frag" function as the pixel (fragment) shader
            #pragma fragment frag

            // vertex shader inputs
            struct appdata
            {
                float4 vertex : POSITION; // vertex position
                float2 uv : TEXCOORD0; // texture coordinate
            };

            // vertex shader outputs ("vertex to fragment")
            struct v2f
            {
                float2 uv : TEXCOORD0; // texture coordinate
                float4 vertex : SV_POSITION; // clip space position
            };

            // vertex shader
            v2f vert (appdata v)
            {
                v2f o;
                // transform position to clip space
                // (multiply with model*view*projection matrix)
                o.vertex = UnityObjectToClipPos(v.vertex);
                // just pass the texture coordinate
                o.uv = v.uv;
                return o;
            }
           
            // texture we will sample
            sampler2D _MainTex;

            // pixel shader; returns low precision ("fixed4" type)
            // color ("SV_Target" semantic)
            fixed4 frag (v2f i) : SV_Target
            {
                // sample texture and return it
                fixed4 col = tex2D(_MainTex, i.uv);
                return col;
            }
            ENDCG
        }
    }
}

Re: Change Custom Provider URL at runtime and Slow loading of map tiles

Yes, the problem is this shader.
Tileset Control uses tiling and offset to correctly display the tiles of previous zoom levels until the tiles of the current zoom level are loaded.

Kind Regards,
Infinity Code Team.

Do not know the best way to thank the developer? Rate the asset in Asset Store!

15 (edited by chema 2019-12-04 12:21:33)

Re: Change Custom Provider URL at runtime and Slow loading of map tiles

The shader I used before was Unlit Transparent (Unity built-in). That shader made the map look good (not dark) but I could not modify it to see the projectors (IgnoreProjector=False). Then I changed it to the shader I just sent you, which solved the projector problem and also the map looked good (not dark). However the tile problem appeared.

Re: Change Custom Provider URL at runtime and Slow loading of map tiles

I modified your shader a bit to make it work:

Shader "Unlit/MapShader"
{
    Properties
    {
        // we have removed support for texture tiling/offset,
        // so make them not be displayed in material inspector
        [NoScaleOffset] _MainTex("Texture", 2D) = "white" {}
    }
    SubShader
    {
        Pass
        {
            CGPROGRAM
            // use "vert" function as the vertex shader
            #pragma vertex vert
            // use "frag" function as the pixel (fragment) shader
            #pragma fragment frag

            #include "UnityCG.cginc"

            // vertex shader inputs
            struct appdata
            {
                float4 vertex : POSITION; // vertex position
                float2 uv : TEXCOORD0; // texture coordinate
            };

            // vertex shader outputs ("vertex to fragment")
            struct v2f
            {
                float2 uv : TEXCOORD0; // texture coordinate
                float4 vertex : SV_POSITION; // clip space position
            };

            sampler2D _MainTex;
            float4 _MainTex_ST;

            // vertex shader
            v2f vert(appdata v)
            {
                v2f o;
                // transform position to clip space
                // (multiply with model*view*projection matrix)
                o.vertex = UnityObjectToClipPos(v.vertex);
                // just pass the texture coordinate
                //o.uv = v.uv;
                o.uv = TRANSFORM_TEX(v.uv, _MainTex);
                return o;
            }

            // texture we will sample
            //sampler2D _MainTex;

            // pixel shader; returns low precision ("fixed4" type)
            // color ("SV_Target" semantic)
            fixed4 frag(v2f i) : SV_Target
            {
                // sample texture and return it
                fixed4 col = tex2D(_MainTex, i.uv);
                return col;
            }
            ENDCG
        }
    }
}
Kind Regards,
Infinity Code Team.

Do not know the best way to thank the developer? Rate the asset in Asset Store!

17 (edited by chema 2019-12-04 12:47:35)

Re: Change Custom Provider URL at runtime and Slow loading of map tiles

THANK YOU SO MUCH!
You are awesome, man smile