Programmatic access to maps and layers

Overview

There are three ways to access Google Maps Engine maps and layers through API libraries:

  • Google Maps API (Visualization Library) - a JavaScript API with a Visualization Library (containing a MapsEngineLayer class) that enables an application to render Maps Engine maps and layers.
  • Google Maps Engine API - a RESTful API that lets you programmatically access values for maps and layers stored in the Maps Engine database.
  • Google Earth API - a JavaScript API that enables an application to render a Maps Engine 3D map using the Google Earth Plug-in.

Google Maps API (Visualization Library)

Requirements:

  • An application based on the Google Maps API.
  • OAuth 2.0 authentication to validate user access to privately published maps.
  • Users who belong to the relevant Maps Engine access lists.

Details:

In the Google Maps API visualization library, the Maps Engine layer lets you render layers of a published Maps Engine map in a map application. When you program with the MapsEngineLayer class, you can display a Google Maps Engine layer on a Maps API map in two different ways:

  • Specify the layer by its mapId and layerKey
  • Specify the layer using its layerId

Obtaining values for mapId and layerKey

  1. In Google Maps Engine, display the Map Details page for the map whose layers you want to use.
  2. Click the link shown here in bold italics:
    Maps API ID: Details
  3. The Maps API ID dialog appears, displaying information similar to what you see in this example:

    Maps API ID 
                
    Map ID: 16802594301115717071-018062511912823249
    
    Layer Name                      Layer key
     
    California ZIP codes            layer_00001 
    California state parks          layer_00002

     
  4. Use the long numeric Map ID value shown in the dialog for the MapsEngineLayer mapId value.
     
  5. Use the Layer key value for the MapsEngineLayer layerKey value.

You can edit the default layer keys to make them more user-friendly and meaningful. You can use any characters, including spaces.

To edit a layer key:

  1. Position the mouse pointer over the current layer key until an edit link appears.
  2. Click the layer key and type the new key into the edit field.
  3. Press the Return or Enter key.

Here's an example of how you can edit names so that they immediately describe the layer content to the user:

Maps API ID 
            
Map ID: 16802594301115717071-01806251191282324927
  
Layer Name                      Layer key

California ZIP codes            ZIP codes 
California state parks          state parks

Obtaining the value for layerId

  1. In Google Maps Engine, display the Layer Details page for the layer you want to use.
  2. Click the link shown here in bold italics:
    Links: Asset ID
  3. The Layer API ID dialog appears, displaying information similar to what you see in this example:
    13933004153574033452-03932489302544561878
    
  4. Use the long numeric Asset ID value shown in the dialog for the MapsEngineLayer layerId value.

Example application:

For an example of a MapsEngineLayer web application, see this map, which shows an imagery layer of NOAA coastline change analysis and a vector layer of urban areas throughout the US. Also see the Google Earth Gallery for additional examples of high-quality Google Maps Engine applications.

Google Maps Engine API

Requirements:

  • An application based on the Google Maps Engine API. The application accesses data stored in the Maps Engine platform.
  • OAuth 2.0 authentication to validate user access to privately published maps.
  • Users who belong to the relevant Maps Engine access lists.

Google Earth API for the Google Earth Plug-in

Requirements:

  • Google Earth Plug-in Client version 6.0.3 or later.
  • To view access-controlled maps, a Google or Google Apps account that is a member of the relevant Maps Engine access list.
  • On a web page, custom JavaScript code that uses Google Earth API to connect to Maps Engine; code must include authentication for private maps.

Details:

To make a Maps Engine 3D map available through Google Earth Plug-in, a web developer must create a custom JavaScript application that uses Google Earth API to connect to a public Maps Engine map. The application can also contain these functions:

  • Perform authentication using OAuth (OAuth 2.0 preferred) for private maps.
  • Request and display published maps.
  • Display the layers of a map that a user requests.

A map viewer must have a supported browser and a supported version of the Google Earth Plug-in.