הוספת מודל תלת-ממדי למפה
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
אתם יכולים להוסיף מודל תלת-ממדי משלכם למפה תלת-ממדית.
בדוגמת הקוד הבאה אפשר לראות איך מוסיפים מודל תלת-ממדי וממקמים אותו במרחב תלת-ממדי באמצעות ה-struct Model
.
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
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-08-31 (שעון UTC).
[null,null,["עדכון אחרון: 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```"]]