Showing addresses on map

Is there a map provider option that does not require Coordinates? I have over 10,000 businesses but only have addresses.

I think this will be a popular feature. Thank you.

For the Leaflet maps we use the openstreetmap free service to convert addresses to coordinates.

It is their Nominatum service:

https://nominatim.openstreetmap.org/ui/search.html

You can call the API with an address and get the coordinate as results.

You can query any address, city

https://nominatim.openstreetmap.org/search?q=amsterdam&format=json

Or find Wappler address:

https://nominatim.openstreetmap.org/search?q=wappler&format=json

Maybe we can build a server action from so you can do it in batches server side and save the coordinates in database. But you can do it directly with the API action as well.

4 Likes

I'm using postcodes.io free api to grab lat and long from postcode. You can also self host.

2 Likes

I know with the Google API you can.. BUT it will cost you a pretty penny at the end of the day... as we used to to this.. reverse the address into coordinates.. and then use the coordinates for the markers..

Maybe this will be a good starting point.. BUT as said.. check the usage.. because once we got a bill for $ 980 ...

1 Like

Yeah, some way to convert large batches would be great. Or even convert individually when they are called would be great. I have almost 12,000 businesses listed and too look up coordinates for each one just wouldn't be practical. Too bad, I even had a place on my business profiles reserved for a map.

I'll share a couple of screenshots when I'm at my laptop. Couldn't you just call the api when required on the front end?

1 Like

I would check if the coordinates are already in the database. If they're not, call the api to get them and store them. That way each address is only looked up once and only as needed.

1 Like

That would certainly work, but I think it is way beyond my skill level. I wouldn't even know where to start.

This source does not seem to recognize Canadian Postal Codes.

Yes, that would be great! :beers:

1 Like

Just my two cents here:

If you're using nominatum to geocode an address you can use some params like:
amenity, street, city, county, state, postalcode, country in a structured query.

For example, Google HQ are on 1600 Amphitheatre Parkway, Mountain View, United States
So you have the street name, the street number, the city, and the country.

Your API will search this:
https://nominatim.openstreetmap.org/search?street=1600+Amphitheatre+Parkway&city=Mountain+View&country=United+States&format=json

And the result is this:

Which is exactly the place:
image

Just note that you can't use those params on a singular query like search?q=someinfohere.
Of course that search?q= will bring more results, but maybe not as specific as the structured.
Depending on what's your situation, you have two ways.


You can use a repeat for every address, then search the coordinates from the structured API (the regular search maybe is not so accurate for this) then insert to the table both results.

1 Like

LOL>. did you see todays news :wink: Leaflet Maps .... as if you asked for it... custom made just for you :slight_smile:

Hi Brad

Do the usual Database Single Query to get the data. Add a condition to check if the longitude has a value. If it does, do nothing more and use the coordinates in the data. If it doesn't, use an API call to whatever service you want to use (postcodes.io looks ideal) and send the address to it and get back the coordinates. Do a Database Update and put those coordinates in.

Let me know how you get on.