Skip to content

Commit 48fe31f

Browse files
committed
Update version; improve comments
1 parent e31fc46 commit 48fe31f

9 files changed

Lines changed: 43 additions & 39 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Add to your `build.gradle.kts`:
1414

1515
```kotlin
1616
dependencies {
17-
implementation("de.afarber:openmapview:0.11.0")
17+
implementation("de.afarber:openmapview:0.12.0")
1818
}
1919
```
2020

docs/PERFORMANCE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ HttpClient(Android) {
269269
All requests include a user-agent header as required by OSM tile usage policy:
270270

271271
```kotlin
272-
header("User-Agent", "OpenMapView/0.11.0 (https://github.com/afarber/OpenMapView)")
272+
header("User-Agent", "OpenMapView/0.12.0 (https://github.com/afarber/OpenMapView)")
273273
```
274274

275275
### Coroutine-Based Downloads

docs/REPLACING_GOOGLE_MAPS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ dependencies {
107107
```kotlin
108108
// Add to build.gradle.kts
109109
dependencies {
110-
implementation("de.afarber:openmapview:0.11.0")
110+
implementation("de.afarber:openmapview:0.12.0")
111111
}
112112
```
113113

examples/Example03Markers/README.md

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
# Example03Markers - Marker Overlays and Interactive Management
1+
# Example03Markers - Marker Navigation and Info Windows
22

33
[Back to README](../../README.md)
44

5-
This example demonstrates the marker system in OpenMapView, including marker rendering, touch detection, info windows, and interactive marker management.
5+
This example demonstrates the marker system in OpenMapView, including marker rendering, touch detection, info windows, and marker navigation.
66

77
## Features Demonstrated
88

99
- Multiple markers at real Bochum landmark locations
1010
- Default teardrop marker icons with color variations
11-
- Both API styles: Kotlin direct instantiation and Google Maps builder pattern
1211
- Marker click detection and selection tracking
13-
- Info windows showing marker titles and snippets
14-
- Interactive marker management (add, remove, clear)
15-
- Real-time status display (marker count, selection, camera state)
16-
- Reset functionality to restore initial state
12+
- Info windows showing marker titles and snippets with auto-dismiss
13+
- Navigation between markers with prev/next buttons
14+
- Info window toggle via FAB or marker tap
15+
- Real-time status display (selection index, camera state)
16+
- Visual feedback when info window is shown (red text)
1717

1818
## Screenshot
1919

@@ -43,8 +43,9 @@ adb shell am start -n de.afarber.openmapview.example03markers/.MainActivity
4343
```
4444
example03markers/
4545
├── MainActivity.kt # Main activity and MapViewScreen composable
46-
├── MarkerToolbar.kt # Horizontal toolbar with add/remove/clear buttons
47-
├── StatusToolbar.kt # Status overlay showing marker count and selection
46+
├── MarkerToolbar.kt # Horizontal toolbar with prev/next navigation buttons
47+
├── StatusToolbar.kt # Status overlay showing selection index and camera state
48+
├── MarkerData.kt # Marker data class and initial Bochum locations
4849
└── Colors.kt # OSM-inspired colors and shared dimensions
4950
```
5051

@@ -57,8 +58,9 @@ example03markers/
5758
fun MapViewScreen() {
5859
val lifecycleOwner = LocalLifecycleOwner.current
5960
var mapView: OpenMapView? by remember { mutableStateOf(null) }
60-
var markerCount by remember { mutableIntStateOf(6) }
61+
var selectedIndex by remember { mutableIntStateOf(0) }
6162
var selectedMarker: Marker? by remember { mutableStateOf(null) }
63+
var isInfoWindowShown by remember { mutableStateOf(false) }
6264

6365
Box(modifier = Modifier.fillMaxSize()) {
6466
AndroidView(
@@ -67,19 +69,24 @@ fun MapViewScreen() {
6769
lifecycleOwner.lifecycle.addObserver(this)
6870
setCenter(initialLocation)
6971
setZoom(13.0f)
72+
getUiSettings().infoWindowAutoDismiss = 10.seconds
7073

7174
setOnMarkerClickListener { marker ->
7275
selectedMarker = marker
76+
isInfoWindowShown = marker.isInfoWindowShown
7377
true
7478
}
79+
setOnInfoWindowCloseListener {
80+
isInfoWindowShown = false
81+
}
7582
mapView = this
7683
}
7784
},
7885
modifier = Modifier.fillMaxSize(),
7986
)
8087

81-
StatusToolbar(markerCount = markerCount, selectedMarkerTitle = selectedMarker?.title, ...)
82-
MarkerToolbar(onAddClick = { ... }, onRemoveClick = { ... }, onClearClick = { ... })
88+
StatusToolbar(selectedIndex, selectedMarker?.title, cameraState, isInfoWindowShown, ...)
89+
MarkerToolbar(onPrevClick = { ... }, onNextClick = { ... })
8390
}
8491
}
8592
```
@@ -112,30 +119,30 @@ addMarker(
112119
### OSM-Inspired Colors (Colors.kt)
113120

114121
```kotlin
115-
val OsmParkGreen = Color(0xFFAAD3A2) // Add button
116-
val OsmHighwayPink = Color(0xFFE892A2) // Remove button, Reset FAB
117-
val OsmWaterBlue = Color(0xFFAAD3DF) // Clear button
122+
val OsmParkGreen = Color(0xFFAAD3A2) // Navigation buttons (prev/next)
123+
val OsmHighwayPink = Color(0xFFE892A2) // Info window toggle FAB
124+
val OsmWaterBlue = Color(0xFFAAD3DF) // Reserved for future use
118125
```
119126

120127
### Key Concepts
121128

122129
- **Marker**: Data class with position, title, snippet, icon, anchor, and tag
123130
- **addMarker()**: Add a marker to the map
124-
- **removeMarker()**: Remove a specific marker
125-
- **clearMarkers()**: Remove all markers
126131
- **getMarkers()**: Get list of all markers
127132
- **setOnMarkerClickListener()**: Handle marker click events
128133
- **setOnInfoWindowClickListener()**: Handle info window click events
134+
- **setOnInfoWindowCloseListener()**: Handle info window close events (manual or auto-dismiss)
135+
- **infoWindowAutoDismiss**: Auto-dismiss info windows after a duration
129136

130137
## What to Test
131138

132139
1. **Launch the app** - you should see 6 colored markers at Bochum landmarks
133-
2. **Tap a marker** - info window shows title and snippet, status shows selection
134-
3. **Tap info window** - toast message confirms the click
135-
4. **Tap + button** - adds new marker at map center
136-
5. **Tap - button** - removes currently selected marker
137-
6. **Tap trash button** - clears all markers
138-
7. **Tap reset FAB** - restores initial markers and camera position
140+
2. **Tap a marker** - info window shows title and snippet, status text turns red
141+
3. **Tap the same marker again** - info window closes, status text turns black
142+
4. **Tap info window** - toast message confirms the click
143+
5. **Tap prev/next buttons** - navigate between markers with camera animation
144+
6. **Tap the FAB** - toggles info window on selected marker
145+
7. **Wait 10 seconds** - info window auto-dismisses, status text turns black
139146
8. **Pan/zoom the map** - markers stay at correct geographic positions
140147

141148
## Marker Locations

examples/Example03Markers/src/main/kotlin/de/afarber/openmapview/example03markers/MainActivity.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ import kotlin.time.Duration.Companion.seconds
4747
* This example showcases:
4848
* - Displaying markers with different colors at real Bochum locations
4949
* - Navigating between markers with prev/next buttons
50-
* - Toggling info windows on selected markers
50+
* - Toggling info windows via FAB or marker tap
5151
* - Camera animation when centering on markers
52-
* - Real-time marker count and selection tracking
52+
* - Real-time selection index and info window state tracking
5353
* - Camera state monitoring
5454
*/
5555
class MainActivity : ComponentActivity() {
@@ -228,7 +228,7 @@ fun MapViewScreen() {
228228
) {
229229
Icon(
230230
imageVector = Icons.Default.LocationOn,
231-
contentDescription = "Reset",
231+
contentDescription = "Toggle Info Window",
232232
)
233233
}
234234
}

examples/Example03Markers/src/main/kotlin/de/afarber/openmapview/example03markers/MarkerToolbar.kt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,9 @@ import androidx.compose.ui.graphics.Color
2424
import androidx.compose.ui.unit.dp
2525

2626
/**
27-
* A horizontal toolbar with buttons to navigate markers.
27+
* A horizontal toolbar with buttons to navigate between markers.
2828
*
29-
* Uses OSM-inspired colors for visual consistency:
30-
* - Previous button: OsmParkGreen
31-
* - Next button: OsmParkGreen
32-
* - Info button: OsmWaterBlue
29+
* Both buttons use OsmParkGreen for visual consistency with OSM styling.
3330
*
3431
* @param onPrevClick Callback invoked when the previous marker button is clicked.
3532
* @param onNextClick Callback invoked when the next marker button is clicked.

examples/Example03Markers/src/main/kotlin/de/afarber/openmapview/example03markers/StatusToolbar.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ import androidx.compose.ui.graphics.Color
2020
import androidx.compose.ui.unit.dp
2121

2222
/**
23-
* A status overlay displaying current marker and camera state information.
23+
* A status overlay displaying current marker selection and camera state.
2424
*
25-
* Shows the currently selected marker index and name, and camera state.
26-
* The marker number text turns red when an info window is shown.
25+
* Shows the currently selected marker index, name, and camera state.
26+
* The marker index text turns red when an info window is shown.
2727
*
2828
* @param selectedIndex The index of the currently selected marker.
2929
* @param selectedMarkerTitle Title of the currently selected marker, or null if none selected.

openmapview/src/main/kotlin/de/afarber/openmapview/TileDownloader.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class TileDownloader {
3333
try {
3434
val response =
3535
client.get(url) {
36-
header("User-Agent", "OpenMapView/0.11.0 (https://github.com/afarber/OpenMapView)")
36+
header("User-Agent", "OpenMapView/0.12.0 (https://github.com/afarber/OpenMapView)")
3737
}
3838
val bytes = response.readRawBytes()
3939
// Decode with RGB_565 to reduce memory usage (2 bytes per pixel vs 4 bytes for ARGB_8888)

openmapview/src/main/kotlin/de/afarber/openmapview/UrlTileProvider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ abstract class UrlTileProvider(
6262
*
6363
* @return User-Agent string
6464
*/
65-
protected open fun getUserAgent(): String = "OpenMapView/0.11.0 (https://github.com/afarber/OpenMapView)"
65+
protected open fun getUserAgent(): String = "OpenMapView/0.12.0 (https://github.com/afarber/OpenMapView)"
6666

6767
/**
6868
* Builds the URL for the specified tile coordinates by replacing placeholders

0 commit comments

Comments
 (0)