3/27/2016

Working Notes on Geolocation & Geocoding for web apps

I'm trying to do some new projects using APIs and phones, communities, addresses, etc.

So, I'm looking at how to get a web visitor's location in the world.
If I know that, then I can determine how to serve best serve them information.

World locations can be described in different ways:

  • Street address, City, State Zip
  • Latitude and Longitude
It's not likely that you're going to have someone's current street address, so Lat & Long coordinates are the better method.

There are many services online that will help you to find these coordinates of your current visitor. You can also use them to find the coordinates of a specific street address.

There are two similar terms that are being used for determining coordinates:
  • Geocoding -- primarily associated with finding Lat & Long for a specified street address.
  • Geolocation -- primarily associated with Lat & Long, often referring to the user's current location.
There's a couple of ways that Geolocation can be determined:
Google Geocoding -- This is an API provided by Google that converts an address to coordinates. The opposite is called Reverse Geocoding. You can use it for free. Technically, you don't even need to register for an API key, but you probably should. Free requests are limited to a cap of 2,500 requests per day. After that, it's $0.50 per 1,000 requests per day (up to 100,000). Billing is done via a registered API key.

The return value from a query is either JSON or XML.

JSON Ex. https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA

To get an API Key:
  • You need to log into your Google account, and then go to this page
  • Click on the button that says [Get A Key].
  • If you have not already created a project, [Create a new Project]. By default this will be called "My Project." It will also assign the project some random unique identifier -- a couple of nonsense words and number.
  • Next you'll be setting up some Credentials. There's different project types that you can be working on that would require an API -- Server key (for server-side scripts), Browser key (for Javascript projects), Android key and iOS key for apps in mobile devices.
  • Once you have your credentials set up, you have to click a button to enable the specific API that you want to use.
  • [The details of this process are too much for me to deal with today... Will come back to this later.]
Google Geolocation -- This is another service from Google, but it differs in that the user's current location is accessed via a POST to the Geolocation API.

I don't know enough about this one yet... Will update later.

Browser Geolocation Object -- This is a built-in function of web browsers. The user has to grant permission for the service to function. When you visit some websites, if geolocation is enabled, a pop-up will appear requesting approval for access to the user's location. The user must choose to grant the site access to teir location.

This process works somehow by using the navigator.geolocation Object.

I don't know nothin' about this yet -- just found out today. Will be back....

1 comment :

  1. This article actually shows your hard work and dedication. To check the external IP, you can also refer to the tool
    https://iplocation.io/
    for getting the IP and its location on maps.

    ReplyDelete