Android Question Open Street Maps not working

Nkalampika

Active Member
Licensed User
hello I use the B4XMap library but open street map shows me an error how to correct this?

 

emexes

Expert
Licensed User
Which particular part at: https://operations.osmfoundation.org/policies/tiles/ was not clear? Your first thought should be: which of those minimum requirements might I have tripped over?

 
Last edited:
Upvote 0

Serge Bertet

Active Member
Licensed User
Usually it is a matter of user-agent, the one in the library is not working, it must be changed.
B4X:
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.Initialize("", Me)
    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
        j.Release
    end if
    return bmp
End Sub
This is what I use, I extracted the class from the library to be able to modify easily .
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…