地図とカメラを操作する
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
カメラのパンや最大高度を制御したり、特定の地図でのユーザーの移動を制限する緯度と経度の境界線を作成したりすることが望ましい場合があります。これを行うには、カメラの制限を使用します。
次の例は、場所の境界を設定してカメラの移動を制限する地図を示しています。
地図の境界を制限
bounds
オプションを設定すると、カメラの地理的境界を制限できます。
次のコードサンプルは、地図の境界を制限する方法を示しています。
async function init() {
const { Map3DElement, MapMode } = await google.maps.importLibrary("maps3d");
const map = new Map3DElement({
center: { lat: 37.7704, lng: -122.3985, altitude: 500 },
tilt: 67.5,
mode: MapMode.HYBRID,
bounds: {south: 37, west: -123, north: 38, east: -121}
});
init();
}
カメラを制限する
次のいずれかのオプションを設定すると、カメラの移動を制限できます。
maxAltitude
minAltitude
maxHeading
minHeading
maxTilt
minTilt
次のコードサンプルは、カメラの制限を示しています。
async function init() {
const { Map3DElement, MapMode } = await google.maps.importLibrary("maps3d");
const map = new Map3DElement({
center: { lat: 37.7704, lng: -122.3985, altitude: 500 },
tilt: 67.5,
mode: MapMode.HYBRID,
minAltitude: 1,
maxAltitude: 1000,
minTilt: 35,
maxTilt: 55
});
document.body.append(map);
}
init();
地図とカメラの境界を制限する
地図とカメラの境界を同時に制限できます。次のコードサンプルは、地図とカメラ境界の両方を制限する方法を示しています。
async function init() {
const { Map3DElement, MapMode } = await google.maps.importLibrary("maps3d");
const map = new Map3DElement({
center: { lat: 37.7704, lng: -122.3985, altitude: 500 },
tilt: 67.5,
mode: MapMode.HYBRID,
minAltitude: 1,
maxAltitude: 1000,
minTilt: 35,
maxTilt: 55,
bounds: {south: 37, west: -123, north: 38, east: -121}
});
document.body.append(map);
}
init();
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-04-29 UTC。
[null,null,["最終更新日 2025-04-29 UTC。"],[],[],null,["Select platform: [Android](/maps/documentation/maps-3d/android-sdk/map-camera-restrictions \"View this page for the Android platform docs.\") [iOS](/maps/documentation/maps-3d/ios-sdk/map-camera-restrictions \"View this page for the iOS platform docs.\") [JavaScript](/maps/documentation/javascript/3d/interaction \"View this page for the JavaScript platform docs.\")\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| This product or feature is in Preview (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\n| descriptions](/maps/launch-stages).\n\n\u003cbr /\u003e\n\nIt may be desirable for you to control the camera's pan, maximum altitude, or to\ncreate latitude and longitude boundaries restricting a user's movement in a\ngiven map. You can do this using *camera restrictions*.\n\nThe following example shows a map with location boundaries set to limit the\ncamera's movement:\n\n\nRestrict map bounds\n\nYou can restrict the geographical boundaries of the camera by setting the\n`bounds` option.\n\nThe following code sample demonstrates restricting the map bounds: \n\n async function init() {\n const { Map3DElement, MapMode } = await google.maps.importLibrary(\"maps3d\");\n\n const map = new Map3DElement({\n center: { lat: 37.7704, lng: -122.3985, altitude: 500 },\n tilt: 67.5,\n mode: MapMode.HYBRID,bounds: {south: 37, west: -123, north: 38, east: -121}\n });\n\n init();\n }\n\nRestrict the camera\n\nYou can restrict the movement of the camera by setting any of the following\noptions:\n\n- `maxAltitude`\n- `minAltitude`\n- `maxHeading`\n- `minHeading`\n- `maxTilt`\n- `minTilt`\n\nThe following code sample demonstrates restricting the camera: \n\n async function init() {\n const { Map3DElement, MapMode } = await google.maps.importLibrary(\"maps3d\");\n\n const map = new Map3DElement({\n center: { lat: 37.7704, lng: -122.3985, altitude: 500 },\n tilt: 67.5,\n mode: MapMode.HYBRID,minAltitude: 1,\n maxAltitude: 1000,\n minTilt: 35,\n maxTilt: 55\n });\n\n document.body.append(map);\n }\n\n init();\n\nRestrict map and camera bounds\n\nYou can simultaneously restrict both map and camera bounds. The following code\nsample demonstrates restricting both map and camera boundaries: \n\n async function init() {\n const { Map3DElement, MapMode } = await google.maps.importLibrary(\"maps3d\");\n\n const map = new Map3DElement({\n center: { lat: 37.7704, lng: -122.3985, altitude: 500 },\n tilt: 67.5,\n mode: MapMode.HYBRID,minAltitude: 1,\n maxAltitude: 1000,\n minTilt: 35,\n maxTilt: 55,\n bounds: {south: 37, west: -123, north: 38, east: -121}\n });\n\n document.body.append(map);\n }\n\n init();"]]