What is Elevation API?

The Google Maps Elevation API provides elevation data for all locations on the surface of the earth, including depth locations on the ocean floor (which return negative values). It ensures a robust API development.

Initial Requirement

  • API Key which will be passed in query url.
  • Single OR Multiple Location(Path) where Elevation is required.

How to use?

For getting Elevation – we will need to make request on this url

https://maps.googleapis.com/maps/api/elevation/json?locations=39.7391536,-104.9847034&key=YOUR_API_KEY

Here YOUR_API_KEY should be the api key you have generated from your google account

This service is also available as part of the client-side Google Maps JavaScript API, or for server-side use with the Java Client, Python Client, Go Client and Node.js Client for Google Maps Services.

Google Maps Elevation API can be accessed via an HTTP interface with requests constructed as a URL string where latitude/longitude coordinates are used to identify the locations or path vertices.

You can also test this URL by calling it from an browser, but don’t forget to add API_KEY as a parameter

Client Libraries are also provided by google in order to access this api’s which provide easy interface with native implementation of common tasks.

Understanding Request URL

We will bifergate the Request URL into different parts to understand each element functionality.
Request URL : https://maps.googleapis.com/maps/api/elevation/json?locations=39.7391536,-104.9847034&key=YOUR_API_KEY

It could be parted in four different functions

  • Base Url
  • Output Response Format
  • Location or Path vertices
  • API Key

1.Base URL : https://maps.googleapis.com/maps/api/elevation/
2.Google provides two types of output response format for the response we get from calling api

  • Json (Recommended)
  • Xml

3.Locations (required) defines the location(s) on the earth from which to return elevation data. This parameter takes either a single location as a comma-separated {latitude,longitude} pair (e.g. “40.714728,-73.998672”) or multiple latitude/longitude pairs passed as an array or as an encoded polyline.

4.API Key (required) Your application’s API key. This key identifies your application for purposes of quota management.

More info about creating URL is here

Following would be the response for the above request,

{

“results” : [

{

“elevation” : 1608.637939453125,

“location” : {

“lat” : 39.73915360,

“lng” : -104.98470340

},

“resolution” : 4.771975994110107

}

],

“status” : “OK”

}

The response includes the elevation at that point, in meters, along with the resolution value (the maximum distance between data points from which the elevation was interpolated, in meters).

Understanding Response

  • Status – Response Code
    – OK
    – INVALID_REQUEST
    – OVER_QUERY_LIMIT
    – REQUEST_DENIED
    – UNKNOWN_ERROR
    – If code is not ‘OK’ then there would be ‘error_message’ field in the response but it’ not guaranteed.
  • Elevation
    – Elevation value in meters.
    – If target is above sea level this value will be positive.
    – For below sea level target value will be negative.
  • Resolution
    – Maximum distance between data points from which the elevation was interpolated, in meters.
    – It could be missing if not available with google.
    – Passing multiple points could result into larger Resolution values.
  • Location
    – This object will contain latitude & longitude of the point for which elevation is computed.

For path elevation request ‘result’ contain multiple objects of the lat – lngs & associated elevation for it,

Multiple location elevation request could be done as follows

https://maps.googleapis.com/maps/api/elevation/json?locations=39.7391536,-104.9847034|36.455556,-116.866667&key=YOUR_API_KEY

Each location element should be divided with (“ | “) as shown in above url. Thus allowing us to include more locations where the elevation path is required.

Usage Limit & Billing


Standard Usage Limit

  • 2,500 request per day is FREE.
  • 2,500 is sum of both client & server side request.
  • 512 locations per request
  • Max 50 request per second as a sum of client & server side
  • After free quota is exhausted google will charge $0.50 USD / 1000 additional requests, up to 100,000 daily

Premium Usage Limits

  • Shared daily free quota of 100,000 requests per 24 hours; additional requests applied against the annual purchase of Maps APIs Credits.
  • 512 locations per request.
  • 50* server-side requests per second.

More Info regarding usage plans are given here.

* Default limit. But could be increased by contacting sales at google

These Limitations are kept by google for preventing fraud/wrong usage of the API. Limits could be changed by google without any notice.

If you exceed per day limit then api may stop temporarily for the remaining day but if you exceed it continuously google may block you from using it.

The maximum billable limit defaults to 100,000 requests per day, but you can change this limit from Quotas page of the API in the Google API Console.

Bonus Points

  • Elevation API could be combined with Google Chart API in order to create charts depending upon the values.
  • URLs must be properly encoded to be valid and are limited to 8192 characters for all web services.

Share your feedback with us. Tweet us your thoughts at @LetsNurture.

Want to work with us? We're hiring!