Skip to content

Commit e9f38a9

Browse files
authored
Migrate zoom API from Double to Float and add edge glow effects (#2)
* Add edge effects. Use float to store zoom * Use custom linear gradients * Remove debug logs * Change more zoom values from Double to Float * Check the dimensions
1 parent 30ae1b9 commit e9f38a9

File tree

27 files changed

+538
-155
lines changed

27 files changed

+538
-155
lines changed

examples/Example01Pan/src/main/kotlin/de/afarber/openmapview/example01pan/MainActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fun MapViewScreen() {
5050
lifecycleOwner.lifecycle.addObserver(this)
5151

5252
setCenter(LatLng(51.4661, 7.2491)) // Bochum, Germany
53-
setZoom(14.0)
53+
setZoom(14.0f)
5454

5555
// Set attribution click listener to open OSM copyright page
5656
setOnAttributionClickListener {

examples/Example02Zoom/src/main/kotlin/de/afarber/openmapview/example02zoom/MainActivity.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class MainActivity : ComponentActivity() {
5252
fun MapViewScreen() {
5353
val context = LocalContext.current
5454
val lifecycleOwner = androidx.lifecycle.compose.LocalLifecycleOwner.current
55-
var zoomLevel by remember { mutableStateOf(14.0) }
55+
var zoomLevel by remember { mutableStateOf(14.0f) }
5656
var mapView: OpenMapView? by remember { mutableStateOf(null) }
5757

5858
Box(modifier = Modifier.fillMaxSize()) {
@@ -63,12 +63,17 @@ fun MapViewScreen() {
6363
lifecycleOwner.lifecycle.addObserver(this)
6464

6565
setCenter(LatLng(51.4661, 7.2491)) // Bochum, Germany
66-
setZoom(14.0)
66+
setZoom(14.0f)
6767
mapView = this
6868

6969
// Enable built-in zoom controls
7070
getUiSettings().isZoomControlsEnabled = true
7171

72+
// Add camera move listener to update zoom label
73+
setOnCameraMoveListener {
74+
zoomLevel = getZoom()
75+
}
76+
7277
// Set attribution click listener to open OSM copyright page
7378
setOnAttributionClickListener {
7479
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://www.openstreetmap.org/copyright"))

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ fun MapViewScreen() {
5555

5656
// Center on Bochum, Germany
5757
setCenter(LatLng(51.4661, 7.2491))
58-
setZoom(14.0)
58+
setZoom(14.0f)
5959

6060
// Add several markers around Bochum with different colors
6161
addMarker(

examples/Example04Polylines/src/main/kotlin/de/afarber/openmapview/example04polylines/MainActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ fun MapViewScreen() {
5555

5656
// Center on Bochum, Germany
5757
setCenter(LatLng(51.4661, 7.2491))
58-
setZoom(14.0)
58+
setZoom(14.0f)
5959

6060
// Add a blue polyline (route)
6161
addPolyline(

examples/Example05Camera/src/main/kotlin/de/afarber/openmapview/example05camera/MainActivity.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ fun MapViewScreen() {
7373
lifecycleOwner.lifecycle.addObserver(this)
7474

7575
setCenter(LatLng(51.4620, 7.2480))
76-
setZoom(13.0)
76+
setZoom(13.0f)
7777

7878
// Enable built-in zoom controls
7979
getUiSettings().isZoomControlsEnabled = true
@@ -123,7 +123,7 @@ fun MapViewScreen() {
123123
FloatingActionButton(
124124
onClick = {
125125
mapView?.animateCamera(
126-
CameraUpdateFactory.newLatLngZoom(location1, 15.0),
126+
CameraUpdateFactory.newLatLngZoom(location1, 15.0f),
127127
1000,
128128
object : CancelableCallback {
129129
override fun onFinish() {
@@ -144,7 +144,7 @@ fun MapViewScreen() {
144144
FloatingActionButton(
145145
onClick = {
146146
mapView?.animateCamera(
147-
CameraUpdateFactory.newLatLngZoom(location2, 15.0),
147+
CameraUpdateFactory.newLatLngZoom(location2, 15.0f),
148148
1000,
149149
)
150150
},
@@ -156,7 +156,7 @@ fun MapViewScreen() {
156156
FloatingActionButton(
157157
onClick = {
158158
mapView?.animateCamera(
159-
CameraUpdateFactory.newLatLngZoom(location3, 15.0),
159+
CameraUpdateFactory.newLatLngZoom(location3, 15.0f),
160160
2000,
161161
)
162162
},

examples/Example06Clicks/src/main/kotlin/de/afarber/openmapview/example06clicks/MainActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ fun MapViewScreen() {
6363
lifecycleOwner.lifecycle.addObserver(this)
6464

6565
setCenter(LatLng(51.4661, 7.2491)) // Bochum, Germany
66-
setZoom(14.0)
66+
setZoom(14.0f)
6767

6868
// Set map click listener
6969
setOnMapClickListener(

examples/Example07DraggableMarkers/src/main/kotlin/de/afarber/openmapview/example07draggablemarkers/MainActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ fun MapViewScreen() {
101101
lifecycleOwner.lifecycle.addObserver(this)
102102

103103
setCenter(bochumCenter)
104-
setZoom(13.0)
104+
setZoom(13.0f)
105105

106106
// Set marker drag listener
107107
setOnMarkerDragListener(

examples/Example08Circles/src/main/kotlin/de/afarber/openmapview/example08circles/MainActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ fun MapViewScreen() {
174174
lifecycleOwner.lifecycle.addObserver(this)
175175

176176
setCenter(bochumCenter)
177-
setZoom(12.0)
177+
setZoom(12.0f)
178178

179179
// Add initial demonstration circles
180180
addDemoCircles()

examples/Example09Overlays/src/main/kotlin/de/afarber/openmapview/example09overlays/MainActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ fun MapViewScreen() {
190190
mapView = this
191191
lifecycleOwner.lifecycle.addObserver(this)
192192
setCenter(bochumCenter)
193-
setZoom(12.0)
193+
setZoom(12.0f)
194194
setOnAttributionClickListener {
195195
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://www.openstreetmap.org/copyright"))
196196
context.startActivity(intent)
@@ -229,7 +229,7 @@ fun MapViewScreen() {
229229
mapView = this
230230
lifecycleOwner.lifecycle.addObserver(this)
231231
setCenter(bochumCenter)
232-
setZoom(12.0)
232+
setZoom(12.0f)
233233
setOnAttributionClickListener {
234234
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://www.openstreetmap.org/copyright"))
235235
context.startActivity(intent)

examples/Example10GroundOverlays/src/main/kotlin/de/afarber/openmapview/example10groundoverlays/MainActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ fun MapViewScreen() {
199199
mapView = this
200200
lifecycleOwner.lifecycle.addObserver(this)
201201
setCenter(bochumCenter)
202-
setZoom(13.0)
202+
setZoom(13.0f)
203203
setOnGroundOverlayClickListener { groundOverlay ->
204204
Toast.makeText(context, "Clicked: ${groundOverlay.tag}", Toast.LENGTH_SHORT).show()
205205
}
@@ -237,7 +237,7 @@ fun MapViewScreen() {
237237
mapView = this
238238
lifecycleOwner.lifecycle.addObserver(this)
239239
setCenter(bochumCenter)
240-
setZoom(13.0)
240+
setZoom(13.0f)
241241
setOnGroundOverlayClickListener { groundOverlay ->
242242
Toast.makeText(context, "Clicked: ${groundOverlay.tag}", Toast.LENGTH_SHORT).show()
243243
}

0 commit comments

Comments
 (0)