次のコードサンプルは、setCamera メソッドを呼び出してカメラをプログラムで制御する方法を示しています。このコードサンプルを使用するには、セットアップとアプリに 3D 地図を追加するの手順に沿って、基本的な 3D 地図を含む Android Studio プロジェクトを設定します。次に、MainActivity.kt ファイルに次のコードを追加します。
// Add importsimportcom.google.android.gms.maps3d.model.latLngAltitude...// Add to the onMap3DViewReady method, after the googleMap3D object has been initializedgoogleMap3D.setCamera(camera{center=latLngAltitude{latitude=38.743502longitude=-109.499374altitude=1467.0}heading=350.0tilt=58.1range=138.2roll=0.0})
[null,null,["最終更新日 2025-08-31 UTC。"],[],[],null,["# Configure camera controls\n\nSelect platform: [Android](/maps/documentation/maps-3d/android-sdk/configure-camera-controls \"View this page for the Android platform docs.\") [iOS](/maps/documentation/maps-3d/ios-sdk/configure-camera-controls \"View this page for the iOS platform docs.\") [JavaScript](/maps/documentation/javascript/3d/map-controls \"View this page for the JavaScript platform docs.\")\n\n\u003cbr /\u003e\n\n| This product or feature is Experimental (pre-GA). Pre-GA products and features might have limited support, and changes to pre-GA products and features might not be compatible with other pre-GA versions. Pre-GA Offerings are covered by the [Google\n| Maps Platform Service Specific Terms](https://cloud.google.com/maps-platform/terms/maps-service-terms). For more information, see the [launch stage descriptions](/maps/launch-stages).\n\n\nUsers can control the zoom, tilt, position, and rotation of the camera using gestures on the map.\nYou can also configure the camera programmatically.\n\nThe Camera Position\n-------------------\n\nThe map view is modeled as a **camera** looking at a specific point in a 3D space.\nThe position and orientation of the camera (and hence the rendering of the map) are specified by\nthe following properties: center (a latitude/longitude/altitude location the camera is looking\nat), heading, tilt, range, and roll.\n\n### Center (Latitude/Longitude/Altitude)\n\nThe **center** defines the specific point in 3D space that the camera is observing.\nThis is specified using the `LatLngAltitude` class,\nwhich combines values for latitude, longitude, and altitude. This allows for precise\npositioning of the camera's focal point in three dimensions.\n\n\nThe latitude can be between -90 and 90 degrees, inclusive. Longitude\nranges between -180 and 180 degrees, inclusive. Altitude is specified in meters above\nsea level.\n\n### Heading\n\nThe camera **heading** specifies the direction the camera will point, measured in\ndegrees clockwise from true North. North corresponds to 0 degrees, East to 90 degrees, South to\n180 degrees, and West to 270 degrees. This determines the orientation of the camera around the\nvertical axis of the [center point](#center_location).\n\n### Tilt\n\nThe **tilt** specifies the angle of the camera with respect to the vertical axis,\nmeasured in degrees. A tilt of 0 degrees means the camera is pointing straight down towards the\nEarth ([nadir](https://en.wikipedia.org/wiki/Nadir)). A tilt of 90\ndegrees means the camera is pointed horizontally in the direction\nspecified by the [heading](#heading_orientation).\n\n### Range\n\nThe **range** defines the distance in meters between the camera's own position and\nthe [center point](#center_location) it is looking at. The range can vary from zero\nmeters (very close up) up to sixty-three million meters, allowing for views from very close up all\nthe way to a truly global perspective. This effectively controls how \"zoomed in\" or \"zoomed out\"\nthe map appears.\n\n### Roll\n\n\nThe **roll** sets the angle of the camera with respect to the horizon,\nmeasured in degrees. This parameter can be used to create effects like banking during flight\nsimulations or even a full barrel roll, rotating the camera around its viewing axis.\n\nControlling the camera\n----------------------\n\nThe following code sample demonstrates how to control the camera\nprogrammatically by calling the\n[`setCamera`](/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/GoogleMap3D#setCamera(com.google.android.gms.maps3d.model.Camera))\nmethod.\nTo use this code sample, follow the instructions in\n[Setup](/maps/documentation/maps-3d/android-sdk/setup) and\n[Add a 3D map to your app](/maps/documentation/maps-3d/android-sdk/add-a-3d-map) to set\nup your Android Studio project with a basic 3D map. Then, add the following\ncode to the\n**`MainActivity.kt`** file: \n\n```kotlin\n// Add imports\nimport com.google.android.gms.maps3d.model.latLngAltitude\n\n...\n\n// Add to the onMap3DViewReady method, after the googleMap3D object has been initialized\ngoogleMap3D.setCamera(\n camera {\n center = latLngAltitude {\n latitude = 38.743502\n longitude = -109.499374\n altitude = 1467.0\n }\n heading = 350.0\n tilt = 58.1\n range = 138.2\n roll = 0.0\n }\n)\n```"]]