Skip to content

Commit 9646df1

Browse files
committed
Add KDoc comments
1 parent 5cd9f99 commit 9646df1

File tree

10 files changed

+529
-0
lines changed

10 files changed

+529
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@
77

88
package de.afarber.openmapview
99

10+
/**
11+
* Represents the camera position for a map.
12+
*
13+
* Defines where the camera is positioned (target location) and how close
14+
* the camera is to the earth's surface (zoom level).
15+
*
16+
* @property target The location that the camera is pointing at
17+
* @property zoom The zoom level, ranging from 2.0 (world view) to 19.0 (street level)
18+
* @throws IllegalArgumentException if zoom is outside the valid range
19+
*/
1020
data class CameraPosition(
1121
val target: LatLng,
1222
val zoom: Double,

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,57 @@
77

88
package de.afarber.openmapview
99

10+
/**
11+
* Defines a camera update to be applied to the map.
12+
*
13+
* Camera updates are created using [CameraUpdateFactory] and applied via
14+
* [OpenMapView.moveCamera] or [OpenMapView.animateCamera].
15+
*
16+
* This is a sealed hierarchy with internal implementations to prevent external subclassing.
17+
*/
1018
sealed class CameraUpdate {
19+
/**
20+
* Updates the camera target to a new location, preserving current zoom.
21+
*/
1122
internal data class NewLatLng(
1223
val target: LatLng,
1324
) : CameraUpdate()
1425

26+
/**
27+
* Updates the camera target and zoom level.
28+
*/
1529
internal data class NewLatLngZoom(
1630
val target: LatLng,
1731
val zoom: Double,
1832
) : CameraUpdate()
1933

34+
/**
35+
* Updates the camera to a new position.
36+
*/
2037
internal data class NewCameraPosition(
2138
val position: CameraPosition,
2239
) : CameraUpdate()
2340

41+
/**
42+
* Increases zoom level by 1.
43+
*/
2444
internal data object ZoomIn : CameraUpdate()
2545

46+
/**
47+
* Decreases zoom level by 1.
48+
*/
2649
internal data object ZoomOut : CameraUpdate()
2750

51+
/**
52+
* Sets zoom to a specific level.
53+
*/
2854
internal data class ZoomTo(
2955
val zoom: Double,
3056
) : CameraUpdate()
3157

58+
/**
59+
* Adjusts zoom by a relative amount (positive to zoom in, negative to zoom out).
60+
*/
3261
internal data class ZoomBy(
3362
val amount: Double,
3463
) : CameraUpdate()

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

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,72 @@
77

88
package de.afarber.openmapview
99

10+
/**
11+
* Factory for creating [CameraUpdate] objects to transform the camera on a map.
12+
*
13+
* Compatible with Google Maps API. Use these methods to create camera updates
14+
* for [OpenMapView.moveCamera] and [OpenMapView.animateCamera].
15+
*/
1016
object CameraUpdateFactory {
17+
/**
18+
* Returns a CameraUpdate that moves the camera to the specified location,
19+
* preserving the current zoom level.
20+
*
21+
* @param target The location to move the camera to
22+
* @return A CameraUpdate for the new location
23+
*/
1124
fun newLatLng(target: LatLng): CameraUpdate = CameraUpdate.NewLatLng(target)
1225

26+
/**
27+
* Returns a CameraUpdate that moves the camera to the specified location
28+
* and sets the zoom level.
29+
*
30+
* @param target The location to move the camera to
31+
* @param zoom The desired zoom level (2.0 to 19.0)
32+
* @return A CameraUpdate for the new location and zoom
33+
*/
1334
fun newLatLngZoom(
1435
target: LatLng,
1536
zoom: Double,
1637
): CameraUpdate = CameraUpdate.NewLatLngZoom(target, zoom)
1738

39+
/**
40+
* Returns a CameraUpdate that moves the camera to the specified position.
41+
*
42+
* @param position The target camera position
43+
* @return A CameraUpdate for the new position
44+
*/
1845
fun newCameraPosition(position: CameraPosition): CameraUpdate = CameraUpdate.NewCameraPosition(position)
1946

47+
/**
48+
* Returns a CameraUpdate that increases the zoom level by 1.
49+
*
50+
* @return A CameraUpdate that zooms in
51+
*/
2052
fun zoomIn(): CameraUpdate = CameraUpdate.ZoomIn
2153

54+
/**
55+
* Returns a CameraUpdate that decreases the zoom level by 1.
56+
*
57+
* @return A CameraUpdate that zooms out
58+
*/
2259
fun zoomOut(): CameraUpdate = CameraUpdate.ZoomOut
2360

61+
/**
62+
* Returns a CameraUpdate that sets the zoom level to the specified value.
63+
*
64+
* @param zoom The target zoom level (2.0 to 19.0)
65+
* @return A CameraUpdate for the specified zoom level
66+
*/
2467
fun zoomTo(zoom: Double): CameraUpdate = CameraUpdate.ZoomTo(zoom)
2568

69+
/**
70+
* Returns a CameraUpdate that adjusts the zoom level by the specified amount.
71+
*
72+
* Positive values zoom in, negative values zoom out.
73+
*
74+
* @param amount The amount to adjust the zoom level (e.g., 1.5 or -2.0)
75+
* @return A CameraUpdate for the relative zoom adjustment
76+
*/
2677
fun zoomBy(amount: Double): CameraUpdate = CameraUpdate.ZoomBy(amount)
2778
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@
77

88
package de.afarber.openmapview
99

10+
/**
11+
* An immutable class representing a pair of latitude and longitude coordinates.
12+
*
13+
* Compatible with Google Maps API. Latitude ranges from -90 to 90 degrees,
14+
* and longitude ranges from -180 to 180 degrees.
15+
*
16+
* @property latitude The latitude in degrees
17+
* @property longitude The longitude in degrees
18+
*/
1019
data class LatLng(
1120
val latitude: Double,
1221
val longitude: Double,

0 commit comments

Comments
 (0)