Google Maps JavaScript API v3

Maximum Zoom Imagery Service

  1. Maximum Zoom Imagery
  2. MaxZoom Requests
  3. MaxZoom Responses

Overview

The Google Maps API provides map tiles at various zoom levels for map type imagery. Most roadmap imagery is available from zoom levels 0 to 18, for example. Satellite imagery varies more widely as this imagery is not generated, but directly photographed.

Because satellite imagery is not always available at high zoom levels for remote locations — sparsely populated areas or open ocean areas — you may want to know the highest zoom level for imagery at a given location beforehand. The MaxZoomService object provides a simple interface for discovering the maximum zoom level at a given location for which Google Maps has satellite imagery.

MaxZoom Requests

Accessing the MaxZoomService is asynchronous, since the Google Maps API needs to make a call to an external server. For that reason, you need to pass a callback method to execute upon completion of the request. This callback method should process the result.

To initiate a request to the MaxZoomService, simply call getMaxZoomAtLatLng(), passing the LatLng of the location and a callback function to execute upon completion of the request.

MaxZoom Responses

When getMaxZoomAtLatLng() executes the callback function, it will pass back two parameters:

  • status contains the MaxZoomStatus of the request.
  • zoom contains the zoom level. If for some reason the service fails, this value will not be present.

The status code may return one of the following values:

  • OK indicates that the service found the maximum zoom level for satellite imagery.
  • ERROR indicates that the MaxZoom request could not be processed.

The following example shows a map of metropolitan Tokyo. Clicking anywhere on the map indicates the maximum zoom level at that location. (Zoom levels around Tokyo generally vary between zoom levels 18 and 21.)

var map;
var maxZoomService = new google.maps.MaxZoomService();

var tokyo = new google.maps.LatLng(35.6894875, 139.6917064);

function initialize() {
  var mapOptions = {
    zoom: 11,
    center: tokyo,
    mapTypeId: google.maps.MapTypeId.HYBRID
  }
  map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);

  google.maps.event.addListener(map, 'click', showMaxZoom);
}

function showMaxZoom(e) {
  maxZoomService.getMaxZoomAtLatLng(e.latLng, function(response) {
    if (response.status != google.maps.MaxZoomStatus.OK) {
      alert("Error in MaxZoomService");
      return;
    } else {
      alert("The maximum zoom at this location is: " + response.zoom);
    }
    map.setCenter(e.latLng);
  });
}

View example (maxzoom-simple.html)

Authentication required

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

Signing you in...

Google Developers needs your permission to do that.