ThinkGeo.com    |     Documentation    |     Premium Support

OSM maps not displaying

All I am getting are the pink tiles with the x in them. I went back to previous builds that were working from a couple of months ago and the same thing occurs in those builds. I thought the OSM servers were down, but Android is accessing OSM and working as it should.

Hi Richard,

That should be the change in server side, view this page https://operations.osmfoundation.org/policies/tiles/ you can see the changes:
Valid HTTP User-Agent identifying application. Faking another app’s User-Agent WILL get you blocked.

And you should want to add the required information in each request:

.UserAgent = "YOUR APP NAME HERE";

The android map have its default UA information so that’s why it works.

For desktop edition the SendingWebRequest event should be helpful.

Regards,

Ethan

Thanks that resolved the issue. For Android how would I set the userAgent to my application name – SendingWebRequest is not present for Android

Hi Richard,

For WPF the default UA is null but I think Android is not the same, if it works I think you don’t need to set the UA for now.

Regards,

Ethan

We’re having the same issue with OpenStreetMap layers in ThinkGeo Server edition (not WPF). How do I modify this code to add a UserAgent?

if (openStreetMapLayer == null)
                    {
                        openStreetMapLayer = new OpenStreetMapLayer();

                        selectedLayers.Add(openStreetMapLayer);
                    }

Hi Tomas,

It looks we have a service edition before, but I don’t know the server edition, could you please let us know your dll version?

And you can try to modify the information you need in the SendingWebRequest event.

Regards,

Ethan

Sorry, I meant ServicesEdition, dll version 9.01085. I never set up the SendingWebRequest manually, just use the OpenStreetMapLayer as mentioned. Do I need to subclass this to be able to do as you suggest, or could you show what you mean?

Thanks,
Tomas

Hi, I was able to solve this by using your tip on the SendingWebRequest event:

                openStreetMapLayer = new OpenStreetMapLayer();
                openStreetMapLayer.SendingWebRequest += osmLayer_SendingWebRequest;
                selectedLayers.Add(openStreetMapLayer);


private void osmLayer_SendingWebRequest(object sender, SendingWebRequestEventArgs sendingWebRequestEventArgs)
{
    ((HttpWebRequest)sendingWebRequestEventArgs.WebRequest).UserAgent = "myappname";
}

Hi Tomas,

Thanks for your share!

It should be helpful if anyone else met the same problem.

Regards,

Ethan

I have added .UserAgent = “YOUR APP NAME HERE”; but, after that every tile (which is not cached) takes much more time to be loaded. The map is a lot slower. Why is this happening? How can I reduce the loading time of tiles?

Hi Mario,

The UserAgent is asked by OpenStreetMap server recently, if you don’t set this parameter the map cannot get tile image. And it’s only a request header, I don’t think it will effect the request performance.

I also test it today, it looks the load speed is still fast.

So I think you can try to get request url in SendingWebRequest event, then copy this url to browser to see whether the speed is the same like it load in map, if that’s the same which maybe a network issue.

And please notice OSM have three servers, the url looks like:

https://a.tile.openstreetmap.org/
https://b.tile.openstreetmap.org/
https://c.tile.openstreetmap.org/

If you found anyone server is special slow in your network, you can replace the URL in SendingWebRequest event or add the others links into CustomServerUris.

For example:

If the a.tile.openstreetmap.org is slow you can just use b and c server

layer.CustomServerUris.Add(new Uri(“http://b.tile.openstreetmap.org/{0}/{1}/{2}.png”))
layer.CustomServerUris.Add(new Uri(“http://c.tile.openstreetmap.org/{0}/{1}/{2}.png”))

I hope that’s able to help you.

Regards,

Ethan

There is not connection problem. Every time I hit a tile uri to my browser is loaded instantly.
I noticed that your demo is also slow after I put the user agent command.
mapsuiteexample
Is this considered to be fast?

As I already said, after the command about user agent my application has been a lot slower. So, I tried several thinks.
First of all, I used the SendingWebRequest and SentWebRequest events and I recorded the time, the thread id and the tile that was requested.
When I load your demo, I noticed that for every tile there are several requests (about 2 but some times more).

This is a part of an excel file that I created based on the times of your demo (the columns is status sending/sent based on the event that make the record, thread id, datetime of the request, uri).
image

image
The same tiles has been requested many times. I just start the app and I did not zoom to another level.

I also created one from my app. The same think happens here too. The same tiles are requested more than once.

image

Why there are so many requests? Is this affect the response time?

Hi Marios,

Generally most tile will be request about 4 times in same extent, parts tiles need be request twice. The reason is because your local tile not match server side tile like this, we have to split and merge them to make the map render in correct position.

image

For avoid it, you can set the tile type equal to single:

    OpenStreetMapOverlay osm = new OpenStreetMapOverlay();
    osm.TileType = TileType.SingleTile;

For your scenario, I think the single tile mode will get faster. But please notice, if the mode is single tile, the map will refresh after all tile images load complete.

The other choice is set the TileHeight and TileWidth to a bigger value, which can reduce some duplication requests.

About the UserAgent, it’s necessary for now, or-else the OSM server will return http 429 error.

We will keep our eyes on OpenStreetMap’s pages and see whether there is any news about the performance improve.

I hope the information is able to help you.

Regards,

Ethan

I tried to set TileType to SingleTile to your demo, but then whenever I zoom or change current extent it stops to respond. Are you sure that OSM Overlay supports SingleTile?

I have another question. In my app I have enabled tile caching. So, why every tile is requested 2 or 4 times, if I have cached it after the first request? Is there a way to restrict it and not allow it to make so many requests and to use the cached tiles?

I want you to know that we are in the last phase of development of our new application and since the OSM policy change and the addition of user agent command, the map (which is the most important feature of the app) has become a lot slower, and this is a drawback that will affect negatively the quality of the app, and we definitelly do not want this.

I have also noticed that the OSM maps are noticeably slower than before userAgent was required.

Hi Mario & Richard,

SingleTile just looks like not respond, please ignore this type if it don’t suitable your scenario.

Because the request is sent nearly at the same time, so the cache image hadn’t generated. The next time you view same extent the cache will works.

For solve the multiply request issue, our developer enhanced the logic, please upgrade all your packages to latest version and set this property:

overlay.MaxExtent = new RectangleShape(-20037508, 20037508, 20037508, -20037508);

For more detail code please view the code in sample attached.

9688.zip (10.9 KB)

I hope that helps solve the issue for you.

Regards,

Ethan

I want to remind you that I use Mapsuite 10. Is something different in 11 or 12 editions related to OSM? Also I tried to upgrade the Nugets from 10.04.00 that I use now, to 10.06.00. But the upgrade proccess damage my .vbproj file (as a result my app did not start) and I had no choice but to revert to the original version. Is there something to the newer versions of these dlls that might help?

I have already asked about the cached files. If every tile is requested 2 or 4 times and caching is enabled, why the last requests are not loading from cached images? If the tile would be requested 2 times, after the first the tile would be cached so the second one must be a lot faster. But this is not happening. Most times the second one is more slow. Is there a way to achieve it? (I have already asked this, but I got no answer).

Hi Mario,

It looks there are some questions here, so I want to list them to make it looks clear.

  1. We only solve this problem(send multiply request for one tile) for version 10 (include pre-release version 11). Version 12 had totally different inner logic, so it don’t have this problem.

  2. You need to upgrade to latest package(pre-release version) to get this change, please download my sample 9688.zip to test, it contains the package version.

  3. We don’t have experience about upgrade from 10.4 to 10.6 damage projection file, we test that today and it looks everything goes well, could you please double check that and if possible did a sample project to reproduce it? Any further information is welcome.

  4. Map run under multi-threading, the last request is sent before the first image get cached. So the cache only will be useful the next time you pan or zoom to same extent. If you found the map even more slower when you zoom back to a cached area please let us know, we can double check that.

Regards,

Ethan

Project 9688.zip uses Version 11 not 12. I did not understand, the last version of 10 still sends multiple requests? If it does, what is the problem that you solve?(I am refering to number 1 from your list). I also want to ask if version 12 has different commands? How hard is to change the version of my app? I need to rewrite the commands which are related to the map? The map is the main feature of our app, and being in the last phase of development make thinks more difficult to do massive changes.

Hi Mario,

I apologies hadn’t noticed our version strategy make you confused, here is some detail information about it:

Version 10.x.x, the release branch for Version 10: it’s based on .net framework
Version 11.0.0-betaxxx, the development branch for Version 10: any changes will be found in this version, after it’s proved stable, we will batch move the changes into release branch

Version 12.x.x, the release branch for Version 12: it’s totally new map version, based on .net core so some features are implemented different than before
Version 13.0.0-betaxxx, the development branch for Version 12

You mentioned you are using version 10, so the package is 11.0.0-betaxxx, you don’t need to change any code because they are the same version. I hope that make sense.

Could you please test the change in your project? If you found it solve your issue without other issue please let us know, we can manual move the change into release branch.

Regards,

Ethan