Android Code Snippet [B4X] Free Geolocation Nominatim (Geocoding API)

Here's a demo of how to use the nominatim geocoding API for free.

Note:
There are other geocoding options if you want to know, leave your comments.

Demo file attached

B4X:
Sub GeoCoderNominatim(Query As String) As ResumableSub
    Dim ResultURL As String
    Dim j As HttpJob
    Dim Parameter() As String = Array As String ("q", Query, "format", "json", "limit", "1", "addressdetails", "1")
    Try
        j.Initialize("", Me)
        j.Download2("https://nominatim.openstreetmap.org/search", Parameter)
        j.GetRequest.SetHeader("Content-Type","application/json")
        Wait For (j) JobDone(j As HttpJob)
        If j.Success Then
            ResultURL = j.GetString
        Else
            Log(j.ErrorMessage)
        End If
    Catch
        Log(LastException)
    End Try
    j.Release
    Return ResultURL
End Sub

Enter address get location

1624173553150.png
1624173572138.png


Enter location get address

1624173639747.png
1624173664177.png
 

Attachments

  • GeoCoderNominatim.zip
    15.9 KB · Views: 692

Wolli013

Well-Known Member
Licensed User
Longtime User
I want to thank you again for this great code!
Is there also something free where you can calculate the correct distance and travel time?
What is that for in your code?


B4X:
#Region Shared Files
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
'Ctrl + click to sync files: ide://run?file=%WINDIR%\System32\Robocopy.exe&args=..\..\Shared+Files&args=..\Files&FilesSync=True
#End Region

'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip
 

TILogistic

Expert
Licensed User
Longtime User
Last edited:

amorosik

Expert
Licensed User

TILogistic

Expert
Licensed User
Longtime User
Not at the moment, but I will post all the classes that can be used with GoogleMaps and GeoCoder.

PS: I will create a post of helper function classes for Google Maps and others, where I will accept donations.
 

imbault

Well-Known Member
Licensed User
Longtime User
Interesting, can we geocode huge numbers of locations using nominatim or OSRM APIs, all is there a fair use ?

Thanks
 

TILogistic

Expert
Licensed User
Longtime User
Interesting, can we geocode huge numbers of locations using nominatim or OSRM APIs, all is there a fair use ?

Thanks
OSRM APIs, all is there a fair use
see:

There are several OSM projects that are community-based and free, some of which have usage policies.
and others where you can have your own mosaic server or geocoder server.
example:
 
Top