Any downloadable API/libraries etc for web based address/GPS functions?

Red Squirrel

No Lifer
May 24, 2003
69,930
13,456
126
www.anyf.ca
I want to add an address field to a website, but I want it to be smart like have auto complete etc, and then actually have some context of the location, either via GPS or some other system. Essentially I want to be able to calculate the distance between two addresses. It's for a food delivery website, and different parts of town will charge differently. So I want the site to actually know where a specific address is so it can then use some logic from that point on.

My first thought was to just go by street, and have a list of every street in the city in a drop down menu, but I actually need to break up some streets too as like say the highway, addresses 1-1000 may be closer than addresses 1001-2000 for example.

So another way I'm thinking is to just do GPS based radius. So anything within 10km is one price, and so on.

Before I try to code all of this myself and manually input all the data is there some kind of API or downloadable set of libraries that I can get that would handle all of this for me?

I was thinking maybe OpenStreetMaps, would it do this? What about adding some GUI functionality to draw stuff on a map like lines, and then save it? I have a separate project where I will want to do stuff like this. Ideally whatever solution I go with I want everything to be on my server, I don't want to depend on a 3rd party. Just wondering where to start looking so I can read up more.
 

mxnerd

Diamond Member
Jul 6, 2007
6,799
1,103
126
Googled.

https://developers.google.com/maps/documentation/distance-matrix/intro

https://www.youtube.com/results?search_query=Distance+Matrix+API

https://developers.google.com/maps/documentation/javascript/geolocation
(Pretty accurate for my case. No address though.
But absolutely won't be correct if user is using VPN )

==

Oops, you said you don't want to depend on 3rd party. :oops:

==

https://www.quora.com/Alternative-to-Google-Maps-Distance-Matrix-API
according to Quora reply, it's free. Not downloadable, though.
(Well, it's free if less than 15,000 transactions per month https://developer.mapquest.com/plans )
https://developer.mapquest.com/documentation/directions-api/#matrix
https://developer.mapquest.com/documentation/samples/directions/v2/route/
you will get turn by turn JSON data.

==
Don't think you want downloadable libraries since map database will change over time.
 
Last edited:

Red Squirrel

No Lifer
May 24, 2003
69,930
13,456
126
www.anyf.ca
Yeah this will be for a web page and not an app. More or less I just want users to be able to enter their address, and the field have auto complete and essentially know that the address is valid or not. Ex: I want it to be able to know where that location is so I can make some distance calculations etc.

It's for a business, so I don't want to depend on 3rd party. Ideally I can have some kind of address database that I can just update from a central source. Would openstreetmaps have any kind of API for that? As far as I understand you can setup your own server for that, just not sure what it entails, can't find much info online as to how to do any of it and their docs are kinda generic.

Worse case scenario I'll see if my city has a list of every street in a spreadsheet format. Can then use some logic with address numbers to get some basic distance measurements. Essentially it's to determine how much a delivery should cost based on the general part of town.

If I can get this to work the client might switch from Chownow to me since I already manage the site anyway.

Thinking of even expanding this so I can offer the service to multiple clients. Lot of places here don't have online ordering and I could approach them.
 

mxnerd

Diamond Member
Jul 6, 2007
6,799
1,103
126
There is https://www.melissa.com/v2/lookups/addresssearch/index website that can search and list street name in the U.S. But you are in Canada. :oops:

==

Tried OpenMapStreets to search my city and use XML download and nothing came out.

==

Found Canada Post offer address autocomplete API, but it costs money.
https://www.google.com/search?q=canada+post+address+autocomplete+api

If you are in big city like Toronto
https://geographic.org/streetview/canada/on/city_of_toronto.html

==

Canada Government Road Network File
https://open.canada.ca/data/en/dataset?q="Road+Network"&keywords=road+network&sort=relevance+asc

Seems newest is 2012 whole Canada.
https://open.canada.ca/data/en/dataset/ea135e2d-87a3-4bf5-9ccb-4f7c2432b280

==

Shapefile to csv
https://www.google.com/search?q=shapefile+to+csv

=====
Well, it seems it's road's info (like from what coordinate to what coordinate ). Not street name info. o_O It might work, but definitely need some effort. :(
 
Last edited:

Red Squirrel

No Lifer
May 24, 2003
69,930
13,456
126
www.anyf.ca
Thanks for the info will check those when I get home. Worse case scenario I might just give in and use an API that relies on an external service, I can maybe implement two and make it easy to flip between them, so if one goes down I can quickly flip it to the other or even automate it if it gets a non HTTP 200 response.
 

mxnerd

Diamond Member
Jul 6, 2007
6,799
1,103
126
Yep.

Using 2 resources is a very good idea,

having a backup is critical for business operation. ;)
 

purbeast0

No Lifer
Sep 13, 2001
53,501
6,338
126
I'm not sure what you mean by you want to download a library or use an API but you don't want to depend on a 3rd party library.

By definition, those are third party libraries.
 

mxnerd

Diamond Member
Jul 6, 2007
6,799
1,103
126
I think Red Squirrel just want to avoid paying 3rd party like Google.

He was thinking whether there were software/database that has address database he can download and use.

But actually Google Map API charges seems very reasonable and minimal.

Free database/software usually mean it's data probably is outdated or incorrect, and hard to use. Also not necessarily has a good API.

There are many open source GIS server, but not necessarily has what RS need/want. I really don't know.
https://www.google.com/search?q=open+source+gis+server
 
Last edited:

Red Squirrel

No Lifer
May 24, 2003
69,930
13,456
126
www.anyf.ca
Meant a 3rd party site. Ex: I want the library/data to reside on my own server so queries don't need to leave the server.

Since I only need to cover my city I might just see if I can find a list of every street. I can probably make it work with just that, and address # range based rules.
 

Red Squirrel

No Lifer
May 24, 2003
69,930
13,456
126
www.anyf.ca
I want to have the data on the server. Less risk of the 3rd party service going down or discontinuing the service etc.

Though ideally I want a way to update the data too. Like a script could run once a month or something.

Honestly figured this would be fairly simple to do where I can just download some kind of database and accompanying php/js files. How do most sites that let you pick an address do it?
 

mxnerd

Diamond Member
Jul 6, 2007
6,799
1,103
126
Have you checked the files available at openaddresses.io/ ?

Now I remembered that it's hard to get free address database, you usually have to buy it from somewhere.

If all you need is the city's street name list, call city hall see if they can provide you with anything.

Street name in Excel file format is the best.

if not , see if they have a printout. Use some Android OCR APP to scan the document and convert it to text / csv file.
 
Last edited:

Red Squirrel

No Lifer
May 24, 2003
69,930
13,456
126
www.anyf.ca
Yeah more I think about it I think I can make due with pretty much just a list of streets, and given this will only really need to cover my city I will just try to get a list from them or at worse just manually enter them. There are some streets that will need to be split up by address ranges but I can add that logic in the system. I kind of wanted a single address field with some kind of auto complete API digging into a local address database but I can probably just split it up by street/house number.

At some point I do want to play around with map stuff (for another project) including having address searching etc but it seems this is not something that will be easy to do.