New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Map doesn't loading Tile Layers in Android #668
Comments
I have the same problem. Mapsui sample works but then I make my own solution the map stays white. I have even copied my source to the Mapsui project and it works just fine. Can't find out what the difference is. I have been chewing on it for 3 days and my customers are getting impatient.... so I hope we can solve the issue soon! |
Hello, I have the same problem too. What you can do as an alternative is to use your own map server or use one of the ones that OSM has, that's what I did, I do not know what's happening. https://wiki.openstreetmap.org/wiki/ES:Teselas
|
@Jesrigt, I did a quick test and you are right! It works for me as well. Strange that this does not happen on iPhone, just Android. My App (which still used 1.4.8) worked well but users with Android 9 (Pie) smartphones started reporting white maps. I tried to catch all Exceptions and noticed a 429 "Too many requests" error when downloading the tiles. That could be related to the issue we are experiencing. |
@Jesrigt I forgot to say thanks for sharing your solution! |
I get this error: 429 (Too Many Requests) when fetching tiles in /Mapsui/Fetcher/TileFetchDispatcher.cs:85 with the OpenStreetMap tiles. Seems a violation of the terms of use. Don't know why this is happening on Android only though... |
@nijsf You're welcome, thanks for commenting on the error |
I have a fix for the issue: Following yesterday's error I read that you need to supply a UserAgent in your http request. So I tried the following change and that works: In BruTile.Web.HttpTileProvider add the UserAgent to your request:
|
@RajeethKalluru Yes, that's right, you are using a tile with these characteristics, check the link that you send to know more. @nijsf Thanks for sharing the solution, you're right I had not read in detail about the UserAgen |
This issue was also affecting me in WPF. I resolved it using a very simple custom ITileSource that forwards requests to a wrapped HttpTileSource that is passed a custom var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Add("User-Agent", USER_AGENT);
var osmAttribution = new Attribution("© OpenStreetMap contributors", "https://www.openstreetmap.org/copyright");
var osmSource = new HttpClientTileSource(httpClient, new GlobalSphericalMercator(), "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", new[] { "a", "b", "c" }, name: "OpenStreetMap", attribution: osmAttribution);
var osmLayer = new TileLayer(osmSource) { Name = "OpenStreetMap" }; using System;
using System.Collections.Generic;
using System.Net.Http;
using BruTile;
using BruTile.Web;
namespace WpfApp1
{
internal class HttpClientTileSource : ITileSource
{
private readonly HttpClient _HttpClient;
private readonly HttpTileSource _WrappedSource;
public HttpClientTileSource(HttpClient httpClient, ITileSchema tileSchema, string urlFormatter, IEnumerable<string> serverNodes = null, string apiKey = null, string name = null, BruTile.Cache.IPersistentCache<byte[]> persistentCache = null, Attribution attribution = null)
{
_HttpClient = httpClient ?? throw new ArgumentNullException(nameof(httpClient));
_WrappedSource = new HttpTileSource(tileSchema, urlFormatter, serverNodes, apiKey, name, persistentCache, ClientFetch, attribution);
}
public ITileSchema Schema => _WrappedSource.Schema;
public string Name => _WrappedSource.Name;
public Attribution Attribution => _WrappedSource.Attribution;
public byte[] GetTile(TileInfo tileInfo) => _WrappedSource.GetTile(tileInfo);
private byte[] ClientFetch(Uri uri) => _HttpClient.GetByteArrayAsync(uri).ConfigureAwait(false).GetAwaiter().GetResult();
}
} |
Yes I have heard this from some of my customers too. The app suddenly started to show the map again. The bottom line is that you cannot rely on it to continue to work like this without the change to the http header, I guess.
… Op 11 jun. 2019 om 11:20 heeft RajeethKalluru ***@***.***> het volgende geschreven:
Now its working fine. But I have done nothing.
Thanks.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@nijsf, Thanks, |
I read it here:
https://operations.osmfoundation.org/policies/tiles/
… Op 17 jun. 2019, om 16:45 heeft RajeethKalluru ***@***.***> het volgende geschreven:
I have a fix for the issue:
Following yesterday's error I read that you need to supply a UserAgent in your http request. So I tried the following change and that works:
In BruTile.Web.HttpTileProvider add the UserAgent to your request:
public HttpTileProvider(IRequest request = null, IPersistentCache<byte[]> persistentCache = null,
Func<Uri, byte[]> fetchTile = null)
{
//Add this header, so OpenStreetMap can track you are not abusing their systems
_httpClient.DefaultRequestHeaders.UserAgent.ParseAdd("YOUR APP NAME HERE");
_request = request ?? new NullRequest();
PersistentCache = persistentCache ?? new NullCache();
_fetchTile = fetchTile ?? FetchTile;
}
@nijsf <https://github.com/nijsf>,
Where did you read that we need to supply UserAgent. If possible please provide the resource it would be helpful.
Thanks,
Rajeethulla.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#668?email_source=notifications&email_token=AAHHVSCPO5UVNVLJM65HJSTP26PRVA5CNFSM4HQ76TXKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODX3M2DY#issuecomment-502713615>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAHHVSHG4XTMG5MYB4PDGNDP26PRVANCNFSM4HQ76TXA>.
|
Thanks for the information. |
On all the forms and UWP samples, they are also blank white pages. |
With the next release we use the new version of BruTile. It has a default values set for the user-agent and will not be blocked by openstreetmap. It is advised though to set a user-agent for your application because if just one osm abuser uses the default user-agent your app will be blocked as well. |
In 2.0.0-beta.26 this is fixed. |
Hi Team,
Map doesn't loading Tile layers in Android showing white screen but loading in UWP.
Please guide how to resolve.
I am attaching the sample project.
MapsUIDemo.zip
Android Map:
UWP Map:
Thanks,
Rajeethulla
The text was updated successfully, but these errors were encountered: