Skip to content

Commit 8c622b6

Browse files
committed
feat: implement Marker Styling and Marker Collisions in Compose MarkersActivity and update status
1 parent 33be374 commit 8c622b6

2 files changed

Lines changed: 68 additions & 7 deletions

File tree

Maps3DSamples/ComposeDemos/app/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ This directory contains the Compose samples for the Android Maps 3D SDK. We use
88
| :--- | :--- | :--- | :--- | :--- |
99
| **Basic Map** | ✅ Done | [HelloMapActivity.kt](src/main/java/com/example/composedemos/hellomap/HelloMapActivity.kt) | <img src="src/main/assets/screenshots/hello_map_screenshot.png" alt="Screenshot" width="121"/> | Displays a basic 3D map with standard satellite imagery and initial camera placement. |
1010
| **Polylines** | ✅ Done | [PolylinesActivity.kt](src/main/java/com/example/composedemos/polylines/PolylinesActivity.kt) | <img src="src/main/assets/screenshots/polylines_screenshot.png" alt="Screenshot" width="121"/> | Demonstrates drawing 3D polylines on the map, including custom colors and widths. |
11-
| **Map Interactions** | 🚧 Skeleton | [MapInteractionsActivity.kt](src/main/java/com/example/composedemos/mapinteractions/MapInteractionsActivity.kt) | | Will demonstrate handling click and drag events on map objects. |
11+
| **Map Interactions** | ✅ Done | [MapInteractionsActivity.kt](src/main/java/com/example/composedemos/mapinteractions/MapInteractionsActivity.kt) | | Demonstrates handling click events on map coordinates and POIs. |
1212
| **Popovers** | ✅ Done | [PopoversActivity.kt](src/main/java/com/example/composedemos/popovers/PopoversActivity.kt) | <img src="src/main/assets/screenshots/popovers_screenshot.png" alt="Screenshot" width="121"/> | Shows how to display interactive popover overlays at specific coordinates on the map. |
1313
| **Camera Controls** | ✅ Done | [CameraControlsActivity.kt](src/main/java/com/example/composedemos/cameracontrols/CameraControlsActivity.kt) | <img src="src/main/assets/screenshots/camera_controls_screenshot.png" alt="Screenshot" width="121"/> | Demonstrates manual control of the camera center, heading, tilt, and range using UI controls. |
1414
| **Polygons** | ✅ Done | [PolygonsActivity.kt](src/main/java/com/example/composedemos/polygons/PolygonsActivity.kt) | <img src="src/main/assets/screenshots/polygons_screenshot.png" alt="Screenshot" width="121"/> | Demonstrates drawing 3D polygons with fill colors and outlines on the map. |
1515
| **Models** | ✅ Done | [ModelsActivity.kt](src/main/java/com/example/composedemos/models/ModelsActivity.kt) | <img src="src/main/assets/screenshots/models_screenshot.png" alt="Screenshot" width="121"/> | Shows how to load and place custom 3D models (gLTF) on the map with position, scale, and orientation. |
16-
| **Markers** | ✅ Done | [MarkersActivity.kt](src/main/java/com/example/composedemos/markers/MarkersActivity.kt) | <img src="src/main/assets/screenshots/markers_screenshot.png" alt="Screenshot" width="121"/> | Demonstrates adding 2D markers with custom icons and anchor points to the 3D map. |
16+
| **Markers** | ✅ Done | [MarkersActivity.kt](src/main/java/com/example/composedemos/markers/MarkersActivity.kt) | <img src="src/main/assets/screenshots/markers_screenshot.png" alt="Screenshot" width="121"/> | Demonstrates 2D markers with custom icons, styled pins (pin configurations), and collision behaviors. |
1717
| **Camera Restrictions** | ✅ Done | [CameraRestrictionsActivity.kt](src/main/java/com/example/composedemos/camerarestrictions/CameraRestrictionsActivity.kt) | <img src="src/main/assets/screenshots/camera_restrictions_screenshot.png" alt="Screenshot" width="121"/> | Shows how to restrict the camera range and center bounds to a specific area. |
1818
| **Flight Simulator** | 🚧 Skeleton | [FlightSimulatorActivity.kt](src/main/java/com/example/composedemos/flightsimulator/FlightSimulatorActivity.kt) | | Will demonstrate a first-person camera view simulating flight. |
1919
| **Routes API** | ✅ Done | [RoutesActivity.kt](src/main/java/com/example/composedemos/routes/RoutesActivity.kt) | <img src="src/main/assets/screenshots/routes_screenshot.png" alt="Screenshot" width="121"/> | Demonstrates loading a route from file, rendering the polyline, and animating a 3D car model along the route using a flow-based engine. |

Maps3DSamples/ComposeDemos/app/src/main/java/com/example/composedemos/markers/MarkersActivity.kt

Lines changed: 66 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.example.composedemos.markers
1818

1919
import android.os.Bundle
20+
import android.widget.Toast
2021
import androidx.activity.ComponentActivity
2122
import androidx.activity.compose.setContent
2223
import androidx.activity.enableEdgeToEdge
@@ -40,6 +41,7 @@ import androidx.compose.ui.graphics.Color
4041
import androidx.compose.ui.semantics.contentDescription
4142
import androidx.compose.ui.semantics.semantics
4243
import androidx.compose.ui.unit.dp
44+
import androidx.compose.ui.platform.LocalContext
4345
import androidx.core.view.WindowCompat
4446
import androidx.core.view.WindowInsetsCompat
4547
import androidx.core.view.WindowInsetsControllerCompat
@@ -49,9 +51,12 @@ import com.google.android.gms.maps3d.model.ImageView
4951
import com.google.android.gms.maps3d.model.Map3DMode
5052
import com.google.android.gms.maps3d.model.camera
5153
import com.google.android.gms.maps3d.model.latLngAltitude
54+
import com.google.android.gms.maps3d.model.CollisionBehavior
5255
import com.google.maps.android.compose3d.GoogleMap3D
5356
import com.google.maps.android.compose3d.MarkerConfig
5457
import com.google.maps.android.compose3d.PopoverConfig
58+
import com.google.maps.android.compose3d.PinConfig
59+
import com.google.maps.android.compose3d.GlyphConfig
5560

5661
class MarkersActivity : ComponentActivity() {
5762
override fun onCreate(savedInstanceState: Bundle?) {
@@ -78,6 +83,7 @@ class MarkersActivity : ComponentActivity() {
7883

7984
@Composable
8085
fun MarkersScreen() {
86+
val context = LocalContext.current
8187
var isMapSteady by remember { mutableStateOf(false) }
8288
var popovers by remember { mutableStateOf(emptyList<PopoverConfig>()) }
8389

@@ -96,21 +102,22 @@ fun MarkersScreen() {
96102
}
97103
}
98104

105+
// 1. Default Image-styled Marker with REQUIRED collision behavior
99106
val alienMarker = remember {
100107
MarkerConfig(
101108
key = "alien",
102109
position = latLngAltitude {
103-
latitude = 44.59054845363309
104-
longitude = -104.715177415273
110+
latitude = 44.590548
111+
longitude = -104.715177
105112
altitude = 10.0
106113
},
107114
altitudeMode = AltitudeMode.RELATIVE_TO_MESH,
108115
styleView = ImageView(R.drawable.alien),
109116
label = "Devil's Tower Alien",
110117
isExtruded = true,
111118
isDrawnWhenOccluded = true,
119+
collisionBehavior = CollisionBehavior.REQUIRED,
112120
onClick = {
113-
// State-driven popover creation! No direct map manipulation.
114121
popovers = listOf(
115122
PopoverConfig(
116123
key = "alien_popover",
@@ -124,7 +131,7 @@ fun MarkersScreen() {
124131
modifier = Modifier.padding(8.dp),
125132
) {
126133
Text(
127-
text = "They didn't just come to sculpt mashed potatoes.",
134+
text = "They didn't just come to sculpt mashed potatoes. 👽",
128135
modifier = Modifier.padding(16.dp),
129136
color = Color.Black,
130137
)
@@ -136,6 +143,60 @@ fun MarkersScreen() {
136143
)
137144
}
138145

146+
// 2. Custom Styled Red Pin with Cyan Icon Glyph and OPTIONAL collision behavior
147+
val redPinMarker = remember {
148+
MarkerConfig(
149+
key = "styled_red_pin",
150+
position = latLngAltitude {
151+
latitude = 44.5902
152+
longitude = -104.7148
153+
altitude = 50.0
154+
},
155+
altitudeMode = AltitudeMode.RELATIVE_TO_GROUND,
156+
label = "Custom Color Pin",
157+
isExtruded = true,
158+
isDrawnWhenOccluded = true,
159+
collisionBehavior = CollisionBehavior.OPTIONAL_AND_HIDES_LOWER_PRIORITY,
160+
pinConfig = PinConfig(
161+
backgroundColor = android.graphics.Color.RED,
162+
borderColor = android.graphics.Color.WHITE,
163+
glyph = GlyphConfig.Color(android.graphics.Color.CYAN)
164+
),
165+
onClick = {
166+
Toast.makeText(context, "Clicked Styled Red Pin!", Toast.LENGTH_SHORT).show()
167+
}
168+
)
169+
}
170+
171+
// 3. Custom Styled Yellow Pin with Text Glyph and OPTIONAL collision behavior
172+
val yellowTextPinMarker = remember {
173+
MarkerConfig(
174+
key = "styled_text_pin",
175+
position = latLngAltitude {
176+
latitude = 44.5895
177+
longitude = -104.7160
178+
altitude = 50.0
179+
},
180+
altitudeMode = AltitudeMode.RELATIVE_TO_GROUND,
181+
label = "Custom Text Pin",
182+
isExtruded = true,
183+
isDrawnWhenOccluded = true,
184+
collisionBehavior = CollisionBehavior.OPTIONAL_AND_HIDES_LOWER_PRIORITY,
185+
pinConfig = PinConfig(
186+
backgroundColor = android.graphics.Color.YELLOW,
187+
borderColor = android.graphics.Color.BLUE,
188+
glyph = GlyphConfig.Text("WY\n⛰️", android.graphics.Color.RED)
189+
),
190+
onClick = {
191+
Toast.makeText(context, "Clicked Wyoming Text Pin!", Toast.LENGTH_SHORT).show()
192+
}
193+
)
194+
}
195+
196+
val allMarkers = remember(alienMarker, redPinMarker, yellowTextPinMarker) {
197+
listOf(alienMarker, redPinMarker, yellowTextPinMarker)
198+
}
199+
139200
Box(
140201
modifier = Modifier
141202
.fillMaxSize()
@@ -145,7 +206,7 @@ fun MarkersScreen() {
145206
GoogleMap3D(
146207
camera = devilsTowerCamera,
147208
mapMode = Map3DMode.HYBRID,
148-
markers = listOf(alienMarker),
209+
markers = allMarkers,
149210
popovers = popovers,
150211
modifier = Modifier.fillMaxSize(),
151212
onMapSteady = {

0 commit comments

Comments
 (0)