Add a 3D model to a map

Select platform: Android iOS JavaScript

A 3D model on a map

The following code sample demonstrates how to add a 3D model and position it in 3D space by calling the addModel method. To use this code sample, follow the instructions in Setup and Add a 3D map to your app to set up your Android Studio project with a basic 3D map. Then, add the following code to the MainActivity.kt file:

// Add imports and define constants
importcom.google.android.gms.maps3d.model.latLngAltitude
valPLANE_URL="https://storage.googleapis.com/gmp-maps-demos/p3d-map/assets/Airplane.glb"
valPLANE_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
}
}
)

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025年11月21日 UTC.