Google Maps API - SPLessons

Google Maps Zoom

Chapter 5

SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

Google Maps Zoom

Google Maps Zoom

shape Introduction

The chapter demonstrates about the Google Maps Zoom and following topics covered.

  • Maximum Zooming Imagery

Maximum zooming imagery

shape Description

Various zooming levels are provide by Google Maps API for viewing a map. The levels 0-18 gives the available roadmap imagery. For a remote locations at high zooming levels the satellite imagery may not available always, by using the MaxZoomService object user can know the maximum zooming level for a preferred location.

A callback method is used to execute the user request and process the result(s). Call the getMaxZoomAtLatLng() object for requesting a MaxZoomService.

Following are the parameters for getMaxZoomAtLatLng() for executing a callback function.

shape Example

The below example demonstrate the simple code for Maximum Zooming imagery for a particular location on a map using the LatLng co-ordinate values.

<!DOCTYPE html>
    <title>Maximum Zoom imagery service</title>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="utf-8">
      html, body {
        height: 100%;
        margin: 0;
        padding: 0;
      #map {
        height: 100%;
    <div id="map"></div>
var map;
var maxZoomService;
var infoWindow;
function initMap() {
  map = new google.maps.Map(document.getElementById('map'), {
    zoom: 11,
    center: {lat: 17.2400, lng: 78.4800},
    mapTypeId: google.maps.MapTypeId.HYBRID
  infoWindow = new google.maps.InfoWindow();
  maxZoomService = new google.maps.MaxZoomService();
  map.addListener('click', showMaxZoom);
function showMaxZoom(e) {
  maxZoomService.getMaxZoomAtLatLng(e.latLng, function(response) {
    if (response.status !== google.maps.MaxZoomStatus.OK) {
      infoWindow.setContent('Error in MaxZoomService');
    } else {
          'The maximum zoom at this location is: ' + response.zoom);
        async defer>


shape Key Points

  • For a Map Type imagery map titles are provide at various zoom levels by Google Maps API.
  • Developer need to pass a call back method to execute completion of the request.

shape Programming

  • Copy the API key obtained from Google Maps API and paste using the JavaScript tag in the code for loading Maps.
  • Set the required Map Properties for better output.
  • Make sure the latitude and longitudes of the required location mentioned to be correct.