Camera restrictions

The following example creates a 3D map positioned in Auckland, New Zealand. The map is restricted to New Zealand. The user can pan and tilt around the country, but can't pan or zoom beyond the restraints set on the map.

Read the documentation.

JavaScript

async function initMap() {
    const { Map3DElement } = await google.maps.importLibrary("maps3d");
    const map = new Map3DElement({
        center: { lat: -36.86, lng: 174.76, altitude: 10000 },
        tilt: 67.5,
        mode: 'HYBRID',
        bounds: { south: -48.30, west: 163.56, north: -32.86, east: -180 },
    });
    document.body.append(map);
}
initMap();

CSS

/* * Always set the map height explicitly to define the size of the div element
 * that contains the map. 
 */
html,
map {
  height: 100%;
}
body {
  height: 100%;
  margin: 0;
  padding: 0;
}

HTML


  
    Map

    
    
  
  
    

Try Sample

Clone Sample

Git and Node.js are required to run this sample locally. Follow these instructions to install Node.js and NPM. The following commands clone, install dependencies and start the sample application.

  git clone https://github.com/googlemaps-samples/js-api-samples.git
  cd samples/3d-camera-boundary
  npm i
  npm start