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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Add to your `build.gradle.kts`:

```kotlin
dependencies {
implementation("de.afarber:openmapview:0.12.0")
implementation("de.afarber:openmapview:0.13.0")
}
```

Expand Down
2 changes: 1 addition & 1 deletion docs/PERFORMANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ HttpClient(Android) {
All requests include a user-agent header as required by OSM tile usage policy:

```kotlin
header("User-Agent", "OpenMapView/0.12.0 (https://github.com/afarber/OpenMapView)")
header("User-Agent", "OpenMapView/0.13.0 (https://github.com/afarber/OpenMapView)")
```

### Coroutine-Based Downloads
Expand Down
2 changes: 1 addition & 1 deletion docs/REPLACING_GOOGLE_MAPS.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ dependencies {
```kotlin
// Add to build.gradle.kts
dependencies {
implementation("de.afarber:openmapview:0.12.0")
implementation("de.afarber:openmapview:0.13.0")
}
```

Expand Down
11 changes: 2 additions & 9 deletions examples/Example01Pan/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fun MapViewScreen() {
factory = { ctx ->
OpenMapView(ctx).apply {
lifecycleOwner.lifecycle.addObserver(this)
setCenter(LatLng(51.4661, 7.2491)) // Bochum, Germany
setCenter(LatLng(51.4661, 7.2491))
setZoom(14.0f)
mapView = this
}
Expand All @@ -81,14 +81,6 @@ fun MapViewScreen() {
}
```

### OSM-Inspired Colors (Colors.kt)

```kotlin
val OsmParkGreen = Color(0xFFAAD3A2) // Parks and forests
val OsmHighwayPink = Color(0xFFE892A2) // Highways and roads
val OsmWaterBlue = Color(0xFFAAD3DF) // Water areas
```

### Key Concepts

- **LatLng**: Represents geographic coordinates (latitude, longitude)
Expand Down Expand Up @@ -117,3 +109,4 @@ val OsmWaterBlue = Color(0xFFAAD3DF) // Water areas
- Location 2 (Green marker): East of center
- Location 3 (Magenta marker): South-West of center
- Initial (Cyan marker): Center position

11 changes: 2 additions & 9 deletions examples/Example02Zoom/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ fun MapViewScreen() {
factory = { ctx ->
OpenMapView(ctx).apply {
lifecycleOwner.lifecycle.addObserver(this)
setCenter(LatLng(51.4661, 7.2491)) // Bochum, Germany
setCenter(LatLng(51.4661, 7.2491))
setZoom(14.0f)
mapView = this
}
Expand All @@ -76,14 +76,6 @@ fun MapViewScreen() {
}
```

### OSM-Inspired Colors (Colors.kt)

```kotlin
val OsmParkGreen = Color(0xFFAAD3A2) // Parks and forests
val OsmHighwayPink = Color(0xFFE892A2) // Highways and roads
val OsmWaterBlue = Color(0xFFAAD3DF) // Water areas
```

### Key Concepts

- **setZoom()**: Sets zoom level (2.0 = world view, 19.0 = street level)
Expand Down Expand Up @@ -122,3 +114,4 @@ OpenMapView uses:
## Map Location

**Default Center:** Bochum, Germany (51.4661N, 7.2491E) at zoom 14.0

33 changes: 6 additions & 27 deletions examples/Example03Markers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ example03markers/
├── MarkerToolbar.kt # Horizontal toolbar with prev/next navigation buttons
├── StatusToolbar.kt # Status overlay showing selection index and camera state
├── MarkerData.kt # Marker data class and Bochum POI locations
└── Constants.kt # Colors, dimensions, and durations
└── Colors.kt # OSM-inspired colors and shared dimensions
```

## Code Highlights
Expand All @@ -68,8 +68,8 @@ fun MapViewScreen() {
OpenMapView(ctx).apply {
lifecycleOwner.lifecycle.addObserver(this)
setCenter(initialLocation)
setZoom(13.0f)
getUiSettings().infoWindowAutoDismiss = 10.seconds
setZoom(15.0f)
getUiSettings().infoWindowAutoDismiss = 5.seconds

setOnMarkerClickListener { marker ->
selectedMarker = marker
Expand Down Expand Up @@ -98,7 +98,7 @@ addMarker(
Marker(
position = LatLng(51.4783, 7.2231),
title = "Bochum Hauptbahnhof",
snippet = "Main railway station",
snippet = "Main Railway Station",
icon = BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED),
)
)
Expand All @@ -116,14 +116,6 @@ addMarker(
)
```

### OSM-Inspired Colors (Constants.kt)

```kotlin
val OsmParkGreen = Color(0xFFAAD3A2) // Navigation buttons (prev/next)
val OsmHighwayPink = Color(0xFFE892A2) // Info window toggle FAB
val OsmWaterBlue = Color(0xFFAAD3DF) // Reserved for future use
```

### Key Concepts

- **Marker**: Data class with position, title, snippet, icon, anchor, and tag
Expand All @@ -132,7 +124,6 @@ val OsmWaterBlue = Color(0xFFAAD3DF) // Reserved for future use
- **setOnMarkerClickListener()**: Handle marker click events
- **setOnInfoWindowClickListener()**: Handle info window click events
- **setOnInfoWindowCloseListener()**: Handle info window close events (manual or auto-dismiss)
- **infoWindowAutoDismiss**: Auto-dismiss info windows after a duration

## What to Test

Expand All @@ -145,19 +136,6 @@ val OsmWaterBlue = Color(0xFFAAD3DF) // Reserved for future use
7. **Wait 10 seconds** - info window auto-dismisses, status text turns black
8. **Pan/zoom the map** - markers stay at correct geographic positions

## Marker Locations

This example displays 6 markers at notable Bochum landmarks:

| Location | Coordinates | Description |
| ----------------- | ------------------- | -------------------- |
| Hauptbahnhof | 51.4783°N, 7.2231°E | Main railway station |
| Ruhr University | 51.4452°N, 7.2622°E | Ruhr-Universitat |
| Rathaus | 51.4816°N, 7.2166°E | City Hall |
| Bermuda3eck | 51.4807°N, 7.2222°E | Entertainment dist. |
| Bergbau-Museum | 51.4892°N, 7.2174°E | Mining Museum |
| Starlight Express | 51.4649°N, 7.2043°E | Musical theater |

## Custom Marker Icons

To use custom marker icons instead of the default teardrop:
Expand Down Expand Up @@ -211,4 +189,5 @@ Click detection uses:

**Default Center:** Calculated from marker positions (~51.47°N, 7.22°E) at zoom 13.0

All 6 markers are positioned around Bochum at real landmark locations.
All 8 markers are positioned around Bochum at real landmark locations.

Binary file modified examples/Example03Markers/screenshot.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ package de.afarber.openmapview.example03markers

import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import kotlin.time.Duration
import kotlin.time.Duration.Companion.seconds

/**
* Constants for the Example03Markers app: colors, dimensions, and durations.
Expand All @@ -27,6 +25,3 @@ val OsmWaterBlue = Color(0xFFAAD3DF)

/** Shared corner radius for all toolbar components (matches Material3 FAB). */
val ToolbarCornerRadius = 16.dp

/** Duration after which info windows are automatically dismissed. */
val InfoWindowAutoDismissDuration: Duration = 5.seconds
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.LocationOn
import androidx.compose.material.icons.filled.LocationSearching
import androidx.compose.material3.FloatingActionButton
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
Expand All @@ -39,6 +39,7 @@ import de.afarber.openmapview.LatLng
import de.afarber.openmapview.Marker
import de.afarber.openmapview.OnCameraMoveStartedListener
import de.afarber.openmapview.OpenMapView
import kotlin.time.Duration.Companion.seconds

/**
* Main activity demonstrating OpenMapView marker navigation.
Expand Down Expand Up @@ -83,7 +84,7 @@ fun MapViewScreen() {
poiMarkers.map { it.position.latitude }.average(),
poiMarkers.map { it.position.longitude }.average(),
)
val initialZoom = 14.0f
val initialZoom = 15.0f

// State variables - mapView is nullable because AndroidView.factory runs after first composition
var mapView: OpenMapView? by remember { mutableStateOf(null) }
Expand Down Expand Up @@ -119,7 +120,7 @@ fun MapViewScreen() {

setCenter(initialLocation)
setZoom(initialZoom)
getUiSettings().infoWindowAutoDismiss = InfoWindowAutoDismissDuration
getUiSettings().infoWindowAutoDismiss = 5.seconds

createMarkers(this)

Expand Down Expand Up @@ -159,6 +160,7 @@ fun MapViewScreen() {

// Status overlay at top
StatusToolbar(
totalCount = poiMarkers.size,
selectedIndex = selectedIndex,
selectedMarkerTitle = selectedMarker?.title,
cameraState = cameraState,
Expand Down Expand Up @@ -212,7 +214,7 @@ fun MapViewScreen() {
.padding(16.dp),
) {
Icon(
imageVector = Icons.Default.LocationOn,
imageVector = Icons.Default.LocationSearching,
contentDescription = "Toggle Info Window",
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ val poiMarkers = listOf(
MarkerData(
position = LatLng(51.4783, 7.2231),
title = "Bochum Hauptbahnhof",
snippet = "Main railway station",
snippet = "Main Railway Station",
hue = BitmapDescriptorFactory.HUE_RED,
),
MarkerData(
position = LatLng(51.4452, 7.2622),
title = "Ruhr University",
snippet = "Ruhr-Universität Bochum",
snippet = "Ruhr-University Bochum",
hue = BitmapDescriptorFactory.HUE_BLUE,
),
MarkerData(
Expand All @@ -46,9 +46,9 @@ val poiMarkers = listOf(
hue = BitmapDescriptorFactory.HUE_GREEN,
),
MarkerData(
position = LatLng(51.4807, 7.2222),
position = LatLng(51.4761, 7.2161),
title = "Bermuda3eck",
snippet = "Entertainment district",
snippet = "Entertainment District",
hue = BitmapDescriptorFactory.HUE_ORANGE,
),
MarkerData(
Expand All @@ -58,9 +58,21 @@ val poiMarkers = listOf(
hue = BitmapDescriptorFactory.HUE_MAGENTA,
),
MarkerData(
position = LatLng(51.4649, 7.2043),
position = LatLng(51.4927, 7.2342),
title = "Starlight Express",
snippet = "Musical theater",
snippet = "Musical Theater",
hue = BitmapDescriptorFactory.HUE_CYAN,
),
MarkerData(
position = LatLng(51.4722, 7.2177),
title = "Schauspielhaus Bochum",
snippet = "Drama Theater",
hue = BitmapDescriptorFactory.HUE_YELLOW,
),
MarkerData(
position = LatLng(51.4854, 7.2278),
title = "Zeiss Planetarium",
snippet = "Domed Astronomy Center",
hue = BitmapDescriptorFactory.HUE_VIOLET,
),
)
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import androidx.compose.ui.unit.dp
* Shows the currently selected marker index, name, and camera state.
* The marker index text turns red when an info window is shown.
*
* @param totalCount Total number of markers.
* @param selectedIndex The index of the currently selected marker.
* @param selectedMarkerTitle Title of the currently selected marker, or null if none selected.
* @param cameraState Current camera state description (e.g., "Idle", "Moving (gesture)").
Expand All @@ -33,6 +34,7 @@ import androidx.compose.ui.unit.dp
*/
@Composable
fun StatusToolbar(
totalCount: Int,
selectedIndex: Int,
selectedMarkerTitle: String?,
cameraState: String,
Expand All @@ -47,7 +49,7 @@ fun StatusToolbar(
horizontalAlignment = Alignment.CenterHorizontally,
) {
Text(
text = "Marker #${selectedIndex + 1}",
text = "Marker #${selectedIndex + 1} of $totalCount",
color = if (isInfoWindowShown) Color.Red else Color.Black,
)
Text(
Expand Down
Loading