The following code sample demonstrates how to use
CameraRestriction
to restrict both the geographical boundaries of the camera and the values of
the camera's altitude, heading, and tilt.
// Add imports and define constantsimportcom.google.android.gms.maps3d.model.AltitudeModeimportcom.google.android.gms.maps3d.model.LatLngAltitudeimportcom.google.android.gms.maps3d.model.cameraRestrictionimportcom.google.android.gms.maps3d.model.latLngAltitudeimportcom.google.android.gms.maps3d.model.latLngBoundsimportcom.google.android.gms.maps3d.model.polygonOptionsconstvalEMPIRE_STATE_BUILDING_LATITUDE=40.748233constvalEMPIRE_STATE_BUILDING_LONGITUDE=-73.985663privateconstvalNYC_SOUTH_WEST_LAT=40.68563088976172privateconstvalNYC_SOUTH_WEST_LNG=-74.05030430240065privateconstvalNYC_NORTH_EAST_LAT=40.85649214337128privateconstvalNYC_NORTH_EAST_LNG=-73.80240973771173privateconstvalMAX_ALTITUDE_NYC_METERS=10000.0privateconstvalMIN_ALTITUDE_NYC_METERS=500.0privatevalnycBounds=latLngBounds{northEastLat=NYC_NORTH_EAST_LATnorthEastLng=NYC_NORTH_EAST_LNGsouthWestLat=NYC_SOUTH_WEST_LATsouthWestLng=NYC_SOUTH_WEST_LNG}// Define the restrictionsvalnycCameraRestriction=cameraRestriction{minAltitude=MIN_ALTITUDE_NYC_METERSmaxAltitude=MAX_ALTITUDE_NYC_METERSminHeading=0.0maxHeading=360.0minTilt=0.0maxTilt=90.0bounds=nycBounds}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-01-29 UTC."],[],[]]