OpenStreetMap’s own servers are run entirely on donated resources. They have strictly limited capacity. Heavy use of OSM tiles adversely affects people’s ability to edit the map, and is an abuse of the individual donations and sponsorship which provide hardware and bandwidth. As a result, we require that users of the tiles abide by this tile usage policy.
Below are the minimum requirements that users of tile.openstreetmap.org must adhere to. These may change in future, depending on available resources. Should any users or patterns of usage nevertheless cause problems to the service, access may still be blocked without prior notice. We will try to contact relevant parties if possible, but cannot guarantee this.
Because OpenStreetMap data is free, many other organisations provide map tiles made from OSM data. If your project doesn’t meet our requirements, you can get OSM-derived map tiles elsewhere.
Do not actively or passively encourage copyright infringement.
Recommended: Do not hardcode any URL to tile.openstreetmap.org as doing so will limit your ability to react if the service is disrupted or blocked. In particular, switching should be possible without requiring a software update.
Valid HTTP User-Agent identifying application. Faking another app’s User-Agent WILL get you blocked. Using a library’s default User-Agent is NOT recommended. If a device automatically sends an X-Requested-With header with an application specific Application ID, this will be considered an acceptable substitute for the HTTP User-Agent, although we still recommend setting a valid HTTP User-Agent for the application.
When coming from a web page, a valid HTTP Referer. Apps generally do not have a HTTP referer.
DO NOT send no-cache headers. (“Cache-Control: no-cache”, “Pragma: no-cache” etc.)
Cache Tile downloads locally according to HTTP Expiry Header, alternatively a minimum of 7 days.
Maximum of 2 download connections. (Unmodified web browsers’ download limits are acceptable.)
Note: modern web browsers in standard configuration generally pass all the above technical requirements.
Bulk downloading is strongly discouraged. Do not download tiles unnecessarily.
In particular, downloading an area of over 250 tiles at zoom level 13 or higher for offline or later usage is forbidden. These tiles are generally not available (cached) on the server in advance, and have to be rendered specifically for those requests, putting an unjustified burden on the available resources.
Usually it is a matter of user-agent, the one in the library is not working, it must be changed.
public Sub getTileFromInternet(aZ As Int,aX As Int,aY As Int) As ResumableSub
Dim j As HttpJob
Dim bmp As B4XBitmap
Dim t As String = aZ & "/" & aX & "/" & aY & ".png"
j.Download("https://a.tile.openstreetmap.org/" & t)
j.GetRequest.SetHeader("User-Agent", "Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.102011-10-16 20:23:10")
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
bmp = j.GetBitmap
This is what I use, I extracted the class from the library to be able to modify easily .