Tips and Tricks On Converting Addresses to GPS Location

I see people graphing addresses on maps all the time. For example, one of my clients,, had me do some work on their system. Here’s a quick “Q” and “A” for people who may be working with this sort of thing in the future:

Q: What’s the easiest way to lookup the gps locations of addresses and then put them on a map?

A: Google maps is by far the easiest and most prolific. Everybody uses it.

Q: Wait, but isn’t it just for nonprofits?

A: Technically, they say so, but I have never seen it enforced. Many businesses use it; as far as I can tell, Google loves the free advertising, but they just want the right to revoke it (again, they never have stopped a business from using it).

Q: Okay, so don’t they limit you to a certain amount of lookups per day?

A: Yes! Its like 15,000, though. You can use a server-side language like “PHP” to “cache” the different address lookups, ┬áthat way you never lookup the same address twice. For example, you could force the user to type in something in the form of a “city-state” combination and then “cache” all city-state lookups. Then, you would only lookup a city ONCE ever! Its very fast.

Q: When developing, any tips?

A: Write a “GPS” class that handles all of the gps-lookups throughout your application. Then, optimize it by caching all city-state lookups, zip code lookups, and address lookups. Also, have the configuration for the script (the “application key”) stored or configurable within the class. I’ve seen people hardcode this in throughout the application… that’s a big “no no.” Don’t do it.

Q: Lets say I have a list of locations (maybe businesses or schools or something) and I want to find all of them within a certain distance of a location. How do I do that?

A: If you took geometry, you probably remember “Pythagrian’s Theorum” (A^2 + B^2 = C^2) and distance formula (C = sqrt(A^2 + B^2). There is a “modified” version of the distance formula that you can use that converts the “A” and “B” from “miles” to “degrees longitude/latitude.” has more information.

  • Share/Bookmark

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *