Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions docs/src/experimental/marker-native-strategy.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,6 @@ val strategy = SimpleNativeParallelStrategy<ActualMarker>(
)
```

#### NativeSpatialMarkerStrategy

Advanced spatial rendering with clustering:

```kotlin
import com.mapconductor.marker.nativestrategy.NativeSpatialMarkerStrategy

val spatialStrategy = NativeSpatialMarkerStrategy<ActualMarker>(
clusteringEnabled = true,
clusterThreshold = 100, // Cluster when > 100 markers in area
geocell = HexGeocellImpl.defaultGeocell()
)
```

## Basic Usage

### Simple Native Manager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
Expand Down Expand Up @@ -52,6 +53,11 @@ fun MultipleBubblesPage(onToggleSidebar: () -> Unit = {}) {
}
}

// Initially open the info bubble
LaunchedEffect(Unit) {
selectedMarkers = markerStates.map { it.id }.toSet()
}

DemoMapPageScaffold(
menuItems = DefaultMapViewItems(initCameraPosition),
onToggleSidebar = onToggleSidebar,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
Expand Down Expand Up @@ -75,6 +76,10 @@ fun RichContentBubblePage(onToggleSidebar: () -> Unit = {}) {
extra = locationInfo,
)

LaunchedEffect(Unit) {
selectedMarker = markerState
}

mapViewState?.let {
MapViewContainer(
modifier = Modifier.fillMaxSize(),
Expand All @@ -89,8 +94,8 @@ fun RichContentBubblePage(onToggleSidebar: () -> Unit = {}) {
info?.let {
InfoBubble(
marker = marker,
bubbleColor = Color.White,
borderColor = Color.Gray,
bubbleColor = if (isDarkTheme) Color.Black else Color.White,
borderColor = if (isDarkTheme) Color.Gray else Color.Black,
contentPadding = 16.dp,
cornerRadius = 12.dp,
) {
Expand All @@ -108,7 +113,7 @@ fun RichContentBubblePage(onToggleSidebar: () -> Unit = {}) {
Text(
text = info.description,
style = MaterialTheme.typography.bodyMedium,
color = Color.Gray,
color = if (isDarkTheme) Color.White else Color.Gray,
)

Spacer(modifier = Modifier.height(8.dp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ fun SimpleTextBubblePage(onToggleSidebar: () -> Unit = {}) {
InfoBubble(marker = marker) {
Text(
text = marker.extra as? String ?: "No information",
color = MaterialTheme.colorScheme.primary,
style = MaterialTheme.typography.bodyMedium,
modifier = Modifier.padding(4.dp),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
Expand Down Expand Up @@ -48,6 +49,10 @@ fun StyledInfoBubblePage(onToggleSidebar: () -> Unit = {}) {
extra = "Point of Interest",
)

LaunchedEffect(Unit) {
selectedMarker = markerState
}

mapViewState?.let {
MapViewContainer(
modifier = Modifier.fillMaxSize(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import com.mapconductor.here.HereActualMarker
import com.mapconductor.mapbox.MapboxActualMarker
import com.mapconductor.marker.nativestrategy.NativeParallelMarkerStrategy
import com.mapconductor.marker.nativestrategy.NativeSpatialMarkerRenderingStrategy
import com.mapconductor.marker.nativestrategy.spatial.NativeRemoteSpatialMarkerStrategy

@Composable
fun PostOfficeMapPage(
Expand All @@ -31,8 +32,7 @@ fun PostOfficeMapPage(
val dataLoader = remember { PostOfficeDataLoader(context) }
val strategies =
remember {
val google = NativeParallelMarkerStrategy<GoogleMapActualMarker>()
// val google = NativeSpatialMarkerStrategy<GoogleMapActualMarker>()
val google = NativeRemoteSpatialMarkerStrategy<GoogleMapActualMarker>(context)
// val google = NativeParallelMarkerStrategy<GoogleMapActualMarker>()
val mapbox = NativeParallelMarkerStrategy<MapboxActualMarker>()
val here = NativeParallelMarkerStrategy<HereActualMarker>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.launch

open class MapViewScope {
val overflowScope = CoroutineScope(Dispatchers.IO)
val markerAddSharedFlow = MutableSharedFlow<MarkerState>(1000)
val markerFlow = MutableStateFlow<MutableMap<String, MarkerState>>(mutableMapOf())
val bubbleFlow = MutableStateFlow<MutableMap<String, InfoBubbleEntry>>(mutableMapOf())
Expand Down Expand Up @@ -67,42 +66,6 @@ fun CollectAndRenderOverlays(
registry.getAll().forEach { overlay ->
@Suppress("UNCHECKED_CAST")
val typedOverlay = overlay as MapOverlay<Any>

// LaunchedEffect(Unit) {
// typedOverlay.flow
// .debounce(100) // Debounce updates for 100ms to prevent excessive rendering
// .collect { items ->
// // typedOverlay.render(items, controller)
//
// if (items.isNotEmpty()) {
// return@collect
// }
//
// // Process items in chunks to prevent main thread blocking
// val chunks = items.values.chunked(500) // Process 50 items at a time
//
// chunks.forEach { chunk ->
// val chunkMap =
// chunk
// .associateBy {
// when (it) {
// is MarkerState -> it.id
// is CircleState -> it.id
// is PolylineState -> it.id
// is PolygonState -> it.id
// is GroundImageState -> it.id
// else -> it.toString()
// }
// }.toMutableMap()
//
// typedOverlay.render(chunkMap, controller)
//
// // Yield to allow other coroutines and UI updates
// yield()
// }
// }
// }

val flowState = typedOverlay.flow.collectAsState()

LaunchedEffect(flowState.value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,6 @@ fun MapViewScope.Marker(state: MarkerState) {
LaunchedEffect(state) {
markerAddSharedFlow.emit(state)
}
// DisposableEffect(Unit) {
// overflowScope.launch {
// markerAddSharedFlow.emit(state)
// }
//
// onDispose {
// val newMap = bubbleFlow.value.toMutableMap()
// newMap.remove(state.id)
// bubbleFlow.value = newMap
// }
// }
}

@Composable
Expand Down

This file was deleted.