הגדרת התנהגות של התנגשויות בין סמנים
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
אתם יכולים להתאים אישית את אופן ההתנגשות של סמנים שאתם מוסיפים למפה תלת-ממדית.
בדוגמת הקוד הבאה מוצג איך להגדיר את collisionBehavior
של מבנה הנתונים Marker
כדי לציין איך סמן צריך להתנהג כשהוא מתנגש עם סמן אחר או עם תווית של מפה.
Swift
Map(camera: $camera, mode: .hybrid) {
Marker(
position: .init(
latitude: 37.794724,
longitude: -122.39442,
altitude: 100.0),
altitudeMode: .relativeToMesh,
collisionBehavior: .optionalAndHidesLowerPriority,
extruded: true,
label: "Marker 1"
)
Marker(
position: .init(
latitude: 37.7943220,
longitude: -122.395073,
altitude: 100.0),
altitudeMode: .relativeToMesh,
collisionBehavior: .required,
extruded: true,
label: "Marker 2"
)
Marker(
position: .init(
latitude: 37.7934108,
longitude: -122.396144,
altitude: 100.0),
altitudeMode: .relativeToMesh,
collisionBehavior: .requiredAndHidesOptional,
extruded: true,
label: "Marker 3"
)
}
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-08-31 (שעון UTC).
[null,null,["עדכון אחרון: 2025-08-31 (שעון UTC)."],[],[],null,["Select platform: [Android](/maps/documentation/maps-3d/android-sdk/configure-marker-collision-behavior \"View this page for the Android platform docs.\") [iOS](/maps/documentation/maps-3d/ios-sdk/configure-marker-collision-behavior \"View this page for the iOS platform docs.\") [JavaScript](/maps/documentation/javascript/3d/marker-collision \"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 customize the collision behavior of markers that you add to a 3D map.\n\nThe following code sample demonstrates how configure the [`collisionBehavior` of the `Marker` struct](/maps/documentation/maps-3d/ios-sdk/reference/Structs/Marker#collisionbehavior) to specify how a marker should behave when it collides with anothermarker or map label. \n\nSwift\n\n```\nMap(camera: $camera, mode: .hybrid) {\n Marker(\n position: .init(\n latitude: 37.794724,\n longitude: -122.39442,\n altitude: 100.0),\n altitudeMode: .relativeToMesh,\n collisionBehavior: .optionalAndHidesLowerPriority,\n extruded: true,\n label: \"Marker 1\"\n )\n \n Marker(\n position: .init(\n latitude: 37.7943220,\n longitude: -122.395073,\n altitude: 100.0),\n altitudeMode: .relativeToMesh,\n collisionBehavior: .required,\n extruded: true,\n label: \"Marker 2\"\n )\n \n Marker(\n position: .init(\n latitude: 37.7934108,\n longitude: -122.396144,\n altitude: 100.0),\n altitudeMode: .relativeToMesh,\n collisionBehavior: .requiredAndHidesOptional,\n extruded: true,\n label: \"Marker 3\"\n )\n}\n \n```"]]