Einer Karte ein 3D‑Modell hinzufügen
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Plattform auswählen:
Android
iOS
JavaScript
Sie können einer 3D-Karte ein eigenes importiertes 3D-Modell hinzufügen.
Im folgenden Codebeispiel wird gezeigt, wie Sie mit der Model
-Struktur ein 3D‑Modell hinzufügen und im 3D‑Raum positionieren.
Swift
struct SimpleModelDemo: View {
@State var camera: Camera = .init(latitude: 37.791376, longitude: -122.397571, altitude: 240, heading: 288.0, tilt: 88.0, roll: 0.0, range: 1500)
@State var balloonModel: Model = .init(
position: .init(
latitude: 37.791376,
longitude: -122.397571,
altitude: 200.0),
url: URL(string: "") ?? URL(fileURLWithPath: fileUrl),
altitudeMode: .relativeToMesh,
scale: .init(x: 5, y: 5, z: 5),
orientation: .init(heading: 0, tilt: 0, roll: 0)
)
var body: some View {
Map(camera: $camera, mode: .satellite) {
balloonModel
}
}
}
private let fileUrl = Bundle.main.url(forResource: "balloon", withExtension: "glb")!.path
Sofern nicht anders angegeben, sind die Inhalte dieser Seite unter der Creative Commons Attribution 4.0 License und Codebeispiele unter der Apache 2.0 License lizenziert. Weitere Informationen finden Sie in den Websiterichtlinien von Google Developers. Java ist eine eingetragene Marke von Oracle und/oder seinen Partnern.
Zuletzt aktualisiert: 2025-08-31 (UTC).
[null,null,["Zuletzt aktualisiert: 2025-08-31 (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\nYou can add your own imported 3D model to a 3D map.\n\nThe following code sample demonstrates how to add a 3D model and position it in 3D space using the [`Model` struct](/maps/documentation/maps-3d/ios-sdk/reference/Structs/Model). \n\n### Swift\n\n```swift\nstruct SimpleModelDemo: View {\n @State var camera: Camera = .init(latitude: 37.791376, longitude: -122.397571, altitude: 240, heading: 288.0, tilt: 88.0, roll: 0.0, range: 1500)\n @State var balloonModel: Model = .init(\n position: .init(\n latitude: 37.791376,\n longitude: -122.397571,\n altitude: 200.0),\n url: URL(string: \"\") ?? URL(fileURLWithPath: fileUrl),\n altitudeMode: .relativeToMesh,\n scale: .init(x: 5, y: 5, z: 5),\n orientation: .init(heading: 0, tilt: 0, roll: 0)\n )\n var body: some View {\n Map(camera: $camera, mode: .satellite) {\n balloonModel\n }\n }\n}\nprivate let fileUrl = Bundle.main.url(forResource: \"balloon\", withExtension: \"glb\")!.path\n\n \n```"]]