Добавить 3D-модель на карту,Добавить 3D-модель на карту
Оптимизируйте свои подборки
Сохраняйте и классифицируйте контент в соответствии со своими настройками.
Выберите платформу: Android iOS JavaScript 
Следующий пример кода демонстрирует, как добавить 3D-модель и разместить её в трёхмерном пространстве, вызвав метод addModel
. Чтобы использовать этот пример кода, следуйте инструкциям в разделах «Настройка» и «Добавление 3D-карты в приложение» , чтобы настроить проект Android Studio с простой 3D-картой. Затем добавьте следующий код в файл MainActivity.kt
:
// Add imports and define constants
import com.google.android.gms.maps3d.model.latLngAltitude
val PLANE_URL = "https://storage.googleapis.com/gmp-maps-demos/p3d-map/assets/Airplane.glb"
val PLANE_SCALE = 0.05
// Add to the onMap3DViewReady method, after the googleMap3D object has been initialized
googleMap3D.setCamera(
camera {
center = latLngAltitude {
latitude = 47.133971
longitude = 11.333161
altitude = 2200.0
}
heading = 221.0
tilt = 65.0
range = 1_200.0
}
)
googleMap3D.addModel(
modelOptions {
id = "plane_model"
position = latLngAltitude {
latitude = 47.133971
longitude = 11.333161
altitude = 2200.0
}
altitudeMode = AltitudeMode.ABSOLUTE
orientation = orientation {
heading = 41.5
tilt = -90.0
roll = 0.0
}
url = PLANE_URL
scale = vector3D {
x = PLANE_SCALE
y = PLANE_SCALE
z = PLANE_SCALE
}
}
)
Если не указано иное, контент на этой странице предоставляется по лицензии Creative Commons "С указанием авторства 4.0", а примеры кода – по лицензии Apache 2.0. Подробнее об этом написано в правилах сайта. Java – это зарегистрированный товарный знак корпорации Oracle и ее аффилированных лиц.
Последнее обновление: 2025-08-29 UTC.
[null,null,["Последнее обновление: 2025-08-29 UTC."],[],[],null,["# Add a 3D model to a map\n\nSelect platform: [Android](/maps/documentation/maps-3d/android-sdk/add-3d-models \"View this page for the Android platform docs.\") [iOS](/maps/documentation/maps-3d/ios-sdk/add-3d-models \"View this page for the iOS platform docs.\") [JavaScript](/maps/documentation/javascript/3d/models \"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\nThe following code sample\ndemonstrates how to add a 3D model and position it in 3D space by calling the\n[`addModel`](/maps/documentation/maps-3d/android-sdk/reference/com/google/android/gms/maps3d/GoogleMap3D#addModel(com.google.android.gms.maps3d.model.ModelOptions))\nmethod. To 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 code to the\n**`MainActivity.kt`** file:\n\n```kotlin\n// Add imports and define constants\nimport com.google.android.gms.maps3d.model.latLngAltitude\nval PLANE_URL = \"https://storage.googleapis.com/gmp-maps-demos/p3d-map/assets/Airplane.glb\"\nval PLANE_SCALE = 0.05\n\n// Add to the onMap3DViewReady method, after the googleMap3D object has been initialized\ngoogleMap3D.setCamera(\n camera {\n center = latLngAltitude {\n latitude = 47.133971\n longitude = 11.333161\n altitude = 2200.0\n }\n heading = 221.0\n tilt = 65.0\n range = 1_200.0\n }\n)\n\ngoogleMap3D.addModel(\n modelOptions {\n id = \"plane_model\"\n position = latLngAltitude {\n latitude = 47.133971\n longitude = 11.333161\n altitude = 2200.0\n }\n altitudeMode = AltitudeMode.ABSOLUTE\n orientation = orientation {\n heading = 41.5\n tilt = -90.0\n roll = 0.0\n }\n url = PLANE_URL\n scale = vector3D {\n x = PLANE_SCALE\n y = PLANE_SCALE\n z = PLANE_SCALE\n }\n }\n)\n```"]]