Google Maps Engine API

Accessing public data (no authentication)

Overview

There's an ever-growing number of public datasets available in Google Maps Engine for use by developers in their map or data visualization applications. You may retrieve this data with a simple HTTP request; no authorization is required, and authentication is accomplished through the use of an APIs Console key.

A sample request is below:

https://www.googleapis.com/mapsengine/v1/tables/12421761926155747447-06672618218968397709/features
  ?version=published
  &key=AIzaSyAzgdOiFagRujMB4kr-vyRTbPw3V6d1bWw

Try it!

The following sections describe each portion of the request.

Before you begin

Before you can make any requests to the Google Maps Engine API, you must activate the API in the Google APIs Console, and create an API key.

Follow the instructions in the Registering Your Application page of the Google Maps Engine API documentation, then return to this page.

Alternatively, you can try to do this tutorial, which will take you through the steps on how to begin using the Google Maps Engine API (including obtaining an API key) and how to access public data. It also covers how to create and access private data.

Making your data public

To make a vector table publicly accessible, log in to your Google Maps Engine account. Google Maps Engine uses access lists to define the type of access, and the people who are granted that access, to maps, layers, and data sources.

If you don't have an access list that is configured as Public on the web, you'll need to create one. Refer to Making data public in the Google Maps Engine help center for instructions.

Then, navigate to your layer and select your public access list in the Published version sharing drop-down list.

Request parameters

The URL for public vector table requests is:

https://www.googleapis.com/mapsengine/v1/tables/tableId/features?parameters

Required URL parameters are:

  • version=published: This indicates that you're accessing the publicly-accessible version of the table in Google Maps Engine.
  • key: The value of the key parameter must be a valid APIs Console key. For instructions on finding your key, read Registering Your Application.

Optional parameters are:

  • limit: Defines an upper bound on the number of features to return.
  • maxResults: Defines an upper bound on the number of features to return per results page. If more results match the request, a nextPageToken is included in the response. The request can be repeated with the nextPageToken as the value of a pageToken parameter to retrieve additional results.
  • orderBy: Determines the order in which features are returned. See the orderBy parameter section for details.
  • pageToken: Accepts the value of a previous request's nextPageToken field. Used to page through results.
  • select: Defines the columns to include in the response. See the select parameter section for details.
  • where: Allows SQL-like logic to be applied to the data. See the where parameter section for details.

For example:

https://www.googleapis.com/mapsengine/v1/tables/12421761926155747447-06672618218968397709/features
  ?version=published
  &key=AIzaSyAzgdOiFagRujMB4kr-vyRTbPw3V6d1bWw
  &limit=100
  &maxResults=50
  &orderBy=LENGTH
  &pageToken=CGQSE0VnTXhPRGtZaHQ3dTJZNkl0d0k
  &select=LENGTH
  &where=LENGTH<0.1

orderBy

When requesting a list of features in a table, you may specify an orderBy value that determines the order in which features are returned.

GET https://www.googleapis.com/mapsengine/v1/tables/tableId/features
  ?select=ST_DISTANCE(location,ST_POINT(1,2)) AS distance
  orderBy=distance DESC
  &limit=50

The following rules apply to ordering:

  • Only one order key is supported.
  • The key must be defined in the SELECT clause. You may assign values to a temporary column alias (in this case distance):

    select=ST_DISTANCE(location,ST_POINT(1,2)) AS distance
      &orderBy=distance
    

    Or you may select an existing column in the table:

    select=location&orderBy=location
    
  • The sort order is stable. Features with identical keys are sorted by id.
  • Sorting defaults to ascending order. You may append ASC or DESC to the orderBy clause to specify an order.

    select=location&orderBy=location DESC
    
  • When including an orderBy parameter, you must also include a limit parameter, whose value is less than or equal to 75.

select

Defines the columns to include in the response. The select parameter accepts column names:

select=location,name,"opening hours"

You may also use a supported geometry function and a column alias:

select="opening hours",ST_DISTANCE(location,ST_POINT(1,2)) AS distance

The response includes only the specified properties, in the same order as they are specified.

When using the select parameter, note the following:

  • Property names are case-sensitive.
  • The request must not specify duplicate or non-existent properties.
  • Property names starting with a letter or an underscore, and followed by letters, numbers, and/or underscores ONLY do not need to be enclosed in quotation marks (e.g. select=prop_1).
  • All other property names must be enclosed in quotation marks (e.g. select="Property One"). Single quotes are not supported.
  • If a property name includes quotation marks or backslashes, these must be escaped with a backslash (e.g. select="Property \"Hello!\"").
  • The geometry property that occurs first in the list will be shown in the geometry field of the GeoJSON output.
  • If there are no geometry properties in the list, the geometry field will be null.

where

The Google Maps Engine API supports a limited SQL-like query language for requesting table features. A SQL-like predicate can be passed as the value of the where parameter, as follows:

GET https://www.googleapis.com/mapsengine/v1/tables/tableId/features?where=age>10
  • The predicate must include a column name from the specified table (age in the example above) and a supported operator:

    >, <, >=, <=, =, <>
    
  • Predicates can be joined with AND and/or OR (note that AND has precedence over OR):

    where=age>10 AND income<=50000
    
  • You may use a supported geometry function:

    where=ST_DISTANCE(location,ST_POINT(1.23,4.56)) > 100
    
  • As with all parts of a request URL, predicates must be URL-encoded:

    where=age%3E10+AND+income%3C%3D50000
    

    Examples in this documentation are not encoded, for ease of reading.

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.