tentone / geo-three

Tile based geographic world map visualization library for threejs
https://tentone.github.io/geo-three/docs/
MIT License
651 stars 105 forks source link

White tiles... #31

Open markbaumgarten opened 2 years ago

markbaumgarten commented 2 years ago

First of all: Thanks for a great project!

Second:

Please see screenshot below. Occasionally my custom handler wants to load tiles that are invalid.

I think this might be the reason for the white region seen. Can anyone point me in the right direction for a fix?

avoiding_white_tiles

This is my Provider code(copied from this project).

export class OurOpenStreetMapsProvider extends GEOTHREE.MapProvider
{
                constructor(address) {super();}
                fetchTile(zoom, x, y)
                {
                    return new Promise((resolve, reject) =>
                    {
                        var image = document.createElement("img");
                        image.onload = function(){resolve(image);};
                        image.onerror = function(){reject();};
                        image.crossOrigin = "anonymous";
                        //image.src = "https://tile.openstreetmap.org/10/546/321.png";
                        //image.src = "https://tile.openstreetmap.org/" + zoom + "/" + x + "/" + y + ".png";
                        image.src = mapserver + zoom + "/" + x + "/" + y + ".png";
                    });
                }
}

This is one of the wrong tile urls:

https://tile.openstreetmap.org/20/560839/328106.png

JannikGM commented 2 years ago

According to https://stackoverflow.com/a/34003577 that server only provides until zoom level 19.

You can also see this when looking at URLs:

markbaumgarten commented 2 years ago

Hi Jannik - thanks for your reply.

This explains the invalid requests. I have now changed my mapprovider settings:

-            mapprovider.maxZoom = 20;
+            mapprovider.maxZoom = 19;

...and it no longer calls the invalid urls on the map server....however I still get the white squares on my map :-( - does anyone know what I can do to fix that?

markbaumgarten commented 2 years ago

Here is an example video of the problem:

https://user-images.githubusercontent.com/2726762/159252064-15cbc230-8404-441e-bada-0a49d2cfcd60.mp4

tentone commented 2 years ago

Hello

Thanks a lot, indeed the problem is related with the zoom levels provided by the openstreetmaps API.

The provider object can be changed to adress this issue by setting the default max level to 19.

The white tiles seem to be related either with a texture upload problem or API response missing. Do you have any warning on the console for these?

Thanks a lot

markbaumgarten commented 2 years ago

No warnings in the console other than these from the initial load of the page - but I believe these are irrelevant:

DevTools failed to load source map: Could not load content for http://localhost:8888/static/vis-timeline-graph2d.min.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
DevTools failed to load source map: Could not load content for http://localhost:8888/static/geo-three/build/geo-three.module.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
DevTools failed to load source map: Could not load content for http://localhost:8888/static/three.js/3d/jsm/libs/dat.gui.module.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE

No additional console output at all when the white tiles appear during my speedy zoom-in/zoom-out.

markbaumgarten commented 2 years ago

Here is a screenshot from the live demo where i have selected openstreetmap twice in the top right corner. white_tiles

markbaumgarten commented 2 years ago

I have decided to change the title of the issue, since this issue is present regardless of the mapprovider and the zoom levels.

Since I am at a loss trying to figure out why, here's another screenshot using the default bing maps.

Hoping to see a fix (event though I think the current state of this project is awesome).

white_with_bing

ligaofeng0901 commented 2 years ago

same problem, and there is no error in network requests

tentone commented 2 years ago

So after some diging i think that i have a solution for this issue.

This is related with texture loading, aparently we have a race condition in the texture usage before load.

I will publish a new package soon on npm so that you can check if it fixes the issue on you side as well.

Thanks a lot!

tentone commented 2 years ago

@markbaumgarten A new version has been published on npm. (0.0.17)

Please test with the new version to check if the bug war fixed!

Thanks a lot once again!

markbaumgarten commented 2 years ago

Nice to see that you are looking into things. It is very much appreciated!

I have replaced the build with the latest version and it seems to still be an issue. Also visible in the live demo version...:

white_tiles

laraduarte commented 1 year ago

same problem on my end. Any updates on this?

markbaumgarten commented 1 year ago

I have found that spinning up my own openstreetmap server helps (did not see any white tiles yet).....

On Mon, Nov 7, 2022, 12:06 laraduarte @.***> wrote:

same problem on my end. Any updates on this?

— Reply to this email directly, view it on GitHub https://github.com/tentone/geo-three/issues/31#issuecomment-1305444596, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAUZW2TJAHHBOGEGEQHJRX3WHDPDDANCNFSM5RELRKIQ . You are receiving this because you were mentioned.Message ID: @.***>

laraduarte commented 1 year ago

@markbaumgarten on that case the issue could be the amount of requests we're doing. Most servers/services limit the amount of requests we can do per second. I will investigate this a little bit more. Maybe adjusting the zoom speed will make the issue go away. Let's see :)

laraduarte commented 1 year ago

So I did an extreme test :D a debug layer on top of Bing layer and it confirmed my suspicion, the bing layer is not requesting the white tiles. I should have log 'loadTexture 13 4095 4093' twice on the console but only the OffscreenCanvas (debug layer) is there!

Any ideas @tentone?

Thanks a lot!

image image image image

laraduarte commented 1 year ago

new discovery @tentone, powerDistance instead of scaleDistance fixes the issue! The new issue is the size of the texts on the map :D, they are a little bit smaller now! What can I do to have the text a little bit bigger?

image image image

Thanks a lot

tentone commented 1 year ago

So I did an extreme test :D a debug layer on top of Bing layer and it confirmed my suspicion, the bing layer is not requesting the white tiles.

I can confirm i have done some testing before and this problem is not related with the tile requests they seem to be working correctly.

I believe the problem is related to texture upload. But still need to perform additional testing to be sure.