Skip to content

Commit 79038a8

Browse files
committed
Drop SATELLITE, HYBRID, TOPO
1 parent 1721355 commit 79038a8

6 files changed

Lines changed: 31 additions & 161 deletions

File tree

docs/PUBLIC_API.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ Methods that must be forwarded from the parent Activity/Fragment.
8181

8282
| Method | Return Type | Status | Notes |
8383
| ------------------------------ | ----------- | --------------- | ------------------------------------------- |
84-
| `setCenter(LatLng)` | `void` | IMPLEMENTED | Direct method, not via GoogleMap pattern |
85-
| `setZoom(double)` | `void` | IMPLEMENTED | Direct method, not via GoogleMap pattern |
86-
| `getZoom()` | `double` | IMPLEMENTED | Direct method, not via GoogleMap pattern |
87-
| `setMapType(int)` | `void` | IMPLEMENTED | Supports NORMAL, TERRAIN, HUMANITARIAN, TOPO, CYCLE, NONE. Throws exception for SATELLITE/HYBRID (requires paid APIs). See MapType constants. |
88-
| `getMapType()` | `int` | IMPLEMENTED | Returns current map type constant |
89-
| `setMapStyle(MapStyleOptions)` | `boolean` | NOT PLANNED | Custom tile sources could provide this |
84+
| `setCenter(LatLng)` | `void` | IMPLEMENTED | Direct method, not via GoogleMap pattern |
85+
| `setZoom(double)` | `void` | IMPLEMENTED | Direct method, not via GoogleMap pattern |
86+
| `getZoom()` | `double` | IMPLEMENTED | Direct method, not via GoogleMap pattern |
87+
| `setMapType(int)` | `void` | IMPLEMENTED | Supports NORMAL, TERRAIN, HUMANITARIAN, CYCLE, NONE. See MapType constants |
88+
| `getMapType()` | `int` | IMPLEMENTED | Returns current map type constant |
89+
| `setMapStyle(MapStyleOptions)` | `boolean` | NOT PLANNED | Custom tile sources could provide this |
9090

9191
---
9292

examples/Example11MapTypes/README.md

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,21 @@ Demonstrates switching between different map types in OpenMapView.
1010
- **Humanitarian** - Humanitarian OSM style (red/orange theme)
1111
- **Cycle** - CyclOSM with cycling infrastructure
1212
- **None** - No base map tiles
13-
- Exception handling for unsupported types (Satellite/Hybrid)
1413
- Dynamic attribution based on active tile source
1514
- Material 3 UI with button controls
1615

1716
## Map Types
1817

1918
OpenMapView supports several free OpenStreetMap-based tile sources:
2019

21-
### Supported Types
22-
2320
| Type | Constant | Description |
2421
|------|----------|-------------|
2522
| Normal | `MapType.NORMAL` | Standard OpenStreetMap road map (default) |
2623
| Terrain | `MapType.TERRAIN` | OpenTopoMap with elevation contour lines and hillshading |
2724
| Humanitarian | `MapType.HUMANITARIAN` | Humanitarian OSM style emphasizing hospitals, schools, water sources |
2825
| Cycle | `MapType.CYCLE` | CyclOSM showing bike lanes, paths, parking, and difficulty ratings |
29-
| Topo | `MapType.TOPO` | Alias for TERRAIN |
3026
| None | `MapType.NONE` | No base map tiles displayed |
3127

32-
### Unsupported Types
33-
34-
| Type | Constant | Reason |
35-
|------|----------|--------|
36-
| Satellite | `MapType.SATELLITE` | Requires paid satellite imagery API (Mapbox, Google, Bing) |
37-
| Hybrid | `MapType.HYBRID` | Requires paid satellite imagery API |
38-
39-
Attempting to use unsupported types throws `UnsupportedOperationException` with a descriptive error message.
40-
4128
## Usage
4229

4330
```kotlin
@@ -49,28 +36,14 @@ mapView.setMapType(MapType.TERRAIN)
4936
// Get current map type
5037
val currentType = mapView.getMapType()
5138

52-
// Handle unsupported types
39+
// Handle invalid types
5340
try {
54-
mapView.setMapType(MapType.SATELLITE)
55-
} catch (e: UnsupportedOperationException) {
41+
mapView.setMapType(99)
42+
} catch (e: IllegalArgumentException) {
5643
Toast.makeText(context, e.message, Toast.LENGTH_LONG).show()
5744
}
5845
```
5946

60-
## API Compatibility
61-
62-
OpenMapView implements the Google Maps Android API map type methods:
63-
64-
```kotlin
65-
// Google Maps API
66-
googleMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN)
67-
val type = googleMap.getMapType()
68-
69-
// OpenMapView (compatible)
70-
openMapView.setMapType(MapType.TERRAIN)
71-
val type = openMapView.getMapType()
72-
```
73-
7447
## Screenshot
7548

7649
![Example11MapTypes Demo](screenshot.gif)

examples/Example11MapTypes/src/main/kotlin/de/afarber/openmapview/example11maptypes/MainActivity.kt

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -158,37 +158,15 @@ fun MapViewScreen() {
158158
)
159159
}
160160

161-
Row(
161+
MapTypeButton(
162+
text = "None",
163+
enabled = currentMapType != MapType.NONE,
164+
onClick = {
165+
mapView?.setMapType(MapType.NONE)
166+
currentMapType = MapType.NONE
167+
},
162168
modifier = Modifier.fillMaxWidth(),
163-
horizontalArrangement = Arrangement.spacedBy(8.dp),
164-
) {
165-
MapTypeButton(
166-
text = "None",
167-
enabled = currentMapType != MapType.NONE,
168-
onClick = {
169-
mapView?.setMapType(MapType.NONE)
170-
currentMapType = MapType.NONE
171-
},
172-
modifier = Modifier.weight(1f),
173-
)
174-
MapTypeButton(
175-
text = "Satellite",
176-
enabled = true,
177-
onClick = {
178-
try {
179-
mapView?.setMapType(MapType.SATELLITE)
180-
currentMapType = MapType.SATELLITE
181-
} catch (e: UnsupportedOperationException) {
182-
android.widget.Toast.makeText(
183-
context,
184-
"Satellite type not supported:\n${e.message}",
185-
android.widget.Toast.LENGTH_LONG,
186-
).show()
187-
}
188-
},
189-
modifier = Modifier.weight(1f),
190-
)
191-
}
169+
)
192170
}
193171
}
194172
}
@@ -215,11 +193,8 @@ fun getMapTypeName(type: Int): String =
215193
when (type) {
216194
MapType.NONE -> "None"
217195
MapType.NORMAL -> "Normal"
218-
MapType.SATELLITE -> "Satellite"
219196
MapType.TERRAIN -> "Terrain"
220-
MapType.HYBRID -> "Hybrid"
221197
MapType.HUMANITARIAN -> "Humanitarian"
222-
MapType.TOPO -> "Topo"
223198
MapType.CYCLE -> "Cycle"
224199
else -> "Unknown ($type)"
225200
}

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

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,17 @@
88
package de.afarber.openmapview
99

1010
/**
11-
* Map type constants compatible with Google Maps Android API.
11+
* Map type constants for OpenMapView.
1212
*
13-
* OpenMapView supports a subset of Google's map types plus additional OSM-specific styles.
13+
* Defines available map tile styles using free OpenStreetMap-based tile sources.
1414
*
15-
* **Supported Types:**
15+
* **Available Types:**
1616
* - [NONE]: No base map tiles
1717
* - [NORMAL]: Standard OpenStreetMap road map (default)
1818
* - [TERRAIN]: Topographic map with contour lines (OpenTopoMap)
1919
* - [HUMANITARIAN]: Humanitarian-focused OSM style
20-
* - [TOPO]: Alias for TERRAIN
2120
* - [CYCLE]: Cycling-focused map style (CyclOSM)
2221
*
23-
* **Unsupported Types (throw exception):**
24-
* - [SATELLITE]: Satellite imagery not available (requires paid API)
25-
* - [HYBRID]: Satellite + labels not available (requires paid API)
26-
*
2722
* @see OpenMapView.setMapType
2823
* @see OpenMapView.getMapType
2924
*/
@@ -41,50 +36,27 @@ object MapType {
4136
*/
4237
const val NORMAL: Int = 1
4338

44-
/**
45-
* Satellite imagery.
46-
*
47-
* **NOT SUPPORTED** - Throws [UnsupportedOperationException].
48-
* Satellite tiles require paid APIs (Mapbox, Google, Bing).
49-
*/
50-
const val SATELLITE: Int = 2
51-
5239
/**
5340
* Topographic terrain map with contour lines.
5441
*
5542
* Uses OpenTopoMap tiles showing elevation, hillshading, and contour lines.
5643
* Zoom levels: 0-17
5744
*/
58-
const val TERRAIN: Int = 3
59-
60-
/**
61-
* Satellite imagery with road and label overlays.
62-
*
63-
* **NOT SUPPORTED** - Throws [UnsupportedOperationException].
64-
* Hybrid maps require paid satellite APIs.
65-
*/
66-
const val HYBRID: Int = 4
45+
const val TERRAIN: Int = 2
6746

6847
/**
6948
* Humanitarian-focused OpenStreetMap style.
7049
*
7150
* Uses Humanitarian OSM tiles with red/orange color scheme.
7251
* Emphasizes hospitals, schools, water sources, and disaster response features.
7352
*/
74-
const val HUMANITARIAN: Int = 5
75-
76-
/**
77-
* Topographic map (same as [TERRAIN]).
78-
*
79-
* Alias for TERRAIN type providing OpenTopoMap tiles.
80-
*/
81-
const val TOPO: Int = 6
53+
const val HUMANITARIAN: Int = 3
8254

8355
/**
8456
* Cycling-focused map style.
8557
*
8658
* Uses CyclOSM tiles emphasizing cycling infrastructure:
8759
* bike lanes, paths, parking, shops, and difficulty ratings.
8860
*/
89-
const val CYCLE: Int = 7
61+
const val CYCLE: Int = 4
9062
}

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

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -368,21 +368,15 @@ class OpenMapView
368368
/**
369369
* Sets the type of map tiles that should be displayed.
370370
*
371-
* OpenMapView supports a subset of Google Maps map types using free OpenStreetMap
372-
* tile sources, plus additional OSM-specific styles.
371+
* OpenMapView provides free OpenStreetMap-based tile sources.
373372
*
374373
* **Supported types:**
375374
* - [MapType.NONE] - No base map tiles
376375
* - [MapType.NORMAL] - Standard road map (default)
377376
* - [MapType.TERRAIN] - Topographic map with contour lines
378377
* - [MapType.HUMANITARIAN] - Humanitarian-focused style
379-
* - [MapType.TOPO] - Alias for TERRAIN
380378
* - [MapType.CYCLE] - Cycling-focused map style
381379
*
382-
* **Unsupported types (throw exception):**
383-
* - [MapType.SATELLITE] - Requires paid satellite imagery API
384-
* - [MapType.HYBRID] - Requires paid satellite imagery API
385-
*
386380
* When the map type changes, the tile cache is cleared and the map is redrawn.
387381
*
388382
* Example:
@@ -392,7 +386,7 @@ class OpenMapView
392386
* ```
393387
*
394388
* @param type The map type constant from [MapType]
395-
* @throws UnsupportedOperationException if type is SATELLITE or HYBRID
389+
* @throws IllegalArgumentException if type is not recognized
396390
* @see MapType
397391
* @see getMapType
398392
*/
@@ -402,27 +396,14 @@ class OpenMapView
402396
when (type) {
403397
MapType.NONE -> null
404398
MapType.NORMAL -> TileSource.STANDARD
405-
MapType.TERRAIN, MapType.TOPO -> TileSource.TOPO
399+
MapType.TERRAIN -> TileSource.TOPO
406400
MapType.HUMANITARIAN -> TileSource.HUMANITARIAN
407401
MapType.CYCLE -> TileSource.CYCLE
408-
MapType.SATELLITE, MapType.HYBRID ->
409-
throw UnsupportedOperationException(
410-
"Map type $type (${
411-
when (type) {
412-
MapType.SATELLITE -> "SATELLITE"
413-
MapType.HYBRID -> "HYBRID"
414-
else -> "unknown"
415-
}
416-
}) is not supported. " +
417-
"Satellite and hybrid maps require paid tile providers (Mapbox, Google, Bing). " +
418-
"OpenMapView only supports free OpenStreetMap tile sources.",
419-
)
420402
else ->
421403
throw IllegalArgumentException(
422404
"Unknown map type: $type. " +
423-
"Valid types are: NONE (0), NORMAL (1), TERRAIN (3), " +
424-
"HUMANITARIAN (5), TOPO (6), CYCLE (7). " +
425-
"SATELLITE (2) and HYBRID (4) are not supported.",
405+
"Valid types are: NONE (0), NORMAL (1), TERRAIN (2), " +
406+
"HUMANITARIAN (3), CYCLE (4).",
426407
)
427408
}
428409
controller.setTileSource(newSource)

openmapview/src/test/kotlin/de/afarber/openmapview/MapTypeTest.kt

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,9 @@ class MapTypeTest {
3232
fun testMapTypeConstants() {
3333
assertEquals(0, MapType.NONE)
3434
assertEquals(1, MapType.NORMAL)
35-
assertEquals(2, MapType.SATELLITE)
36-
assertEquals(3, MapType.TERRAIN)
37-
assertEquals(4, MapType.HYBRID)
38-
assertEquals(5, MapType.HUMANITARIAN)
39-
assertEquals(6, MapType.TOPO)
40-
assertEquals(7, MapType.CYCLE)
35+
assertEquals(2, MapType.TERRAIN)
36+
assertEquals(3, MapType.HUMANITARIAN)
37+
assertEquals(4, MapType.CYCLE)
4138
}
4239

4340
@Test
@@ -63,12 +60,6 @@ class MapTypeTest {
6360
assertEquals(MapType.TERRAIN, mapView.getMapType())
6461
}
6562

66-
@Test
67-
fun testSetMapType_Topo() {
68-
mapView.setMapType(MapType.TOPO)
69-
assertEquals(MapType.TOPO, mapView.getMapType())
70-
}
71-
7263
@Test
7364
fun testSetMapType_Humanitarian() {
7465
mapView.setMapType(MapType.HUMANITARIAN)
@@ -81,28 +72,6 @@ class MapTypeTest {
8172
assertEquals(MapType.CYCLE, mapView.getMapType())
8273
}
8374

84-
@Test
85-
fun testSetMapType_Satellite_ThrowsException() {
86-
val exception =
87-
assertThrows(UnsupportedOperationException::class.java) {
88-
mapView.setMapType(MapType.SATELLITE)
89-
}
90-
assertNotNull(exception.message)
91-
assert(exception.message!!.contains("SATELLITE"))
92-
assert(exception.message!!.contains("not supported"))
93-
}
94-
95-
@Test
96-
fun testSetMapType_Hybrid_ThrowsException() {
97-
val exception =
98-
assertThrows(UnsupportedOperationException::class.java) {
99-
mapView.setMapType(MapType.HYBRID)
100-
}
101-
assertNotNull(exception.message)
102-
assert(exception.message!!.contains("HYBRID"))
103-
assert(exception.message!!.contains("not supported"))
104-
}
105-
10675
@Test
10776
fun testSetMapType_InvalidType_ThrowsException() {
10877
val exception =

0 commit comments

Comments
 (0)