Skip to content

Commit b2f5939

Browse files
committed
update documentation
1 parent 56c4662 commit b2f5939

20 files changed

+486
-18
lines changed

Diff for: .github/workflows/ci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ jobs:
1919
key: ${{ github.ref }}
2020
path: .cache
2121
- run: pip install mkdocs-material
22+
- run: pip install mkdocs-glightbox
2223
- run: mkdocs gh-deploy --force

Diff for: app/src/main/java/com/utsman/osmapp/MainActivity.kt

+20-1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ fun MainGraph(
9999
composable(route = Route.Marker.routeArg) {
100100
MarkerPage()
101101
}
102+
103+
composable(route = Route.Polyline.routeArg) {
104+
PolylinePage()
105+
}
106+
107+
composable(route = Route.Polygon.routeArg) {
108+
PolygonPage()
109+
}
102110
}
103111
}
104112

@@ -125,13 +133,24 @@ fun Main() {
125133
}
126134

127135
Button(onClick = {
128-
//navigation.goToSimpleNode()
136+
navigation.goToPolyline()
129137
}) {
130138
Text(text = "Polyline")
131139
}
140+
141+
Button(onClick = {
142+
navigation.goToPolygon()
143+
}) {
144+
Text(text = "Polygon")
145+
}
132146
}
133147
}
134148

149+
150+
/**
151+
* Playground
152+
* */
153+
135154
@Composable
136155
fun MarkerPage1() {
137156
val depokState = rememberMarkerState(geoPoint = GeoPoint(-6.3970066, 106.8224316))

Diff for: app/src/main/java/com/utsman/osmapp/MarkerPage.kt

+39-3
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,66 @@
11
package com.utsman.osmapp
22

3+
import android.graphics.drawable.Drawable
4+
import androidx.compose.foundation.background
5+
import androidx.compose.foundation.layout.Arrangement
6+
import androidx.compose.foundation.layout.Column
37
import androidx.compose.foundation.layout.fillMaxSize
8+
import androidx.compose.foundation.layout.size
9+
import androidx.compose.foundation.shape.RoundedCornerShape
10+
import androidx.compose.material.Text
411
import androidx.compose.runtime.Composable
12+
import androidx.compose.runtime.getValue
13+
import androidx.compose.runtime.mutableStateOf
14+
import androidx.compose.runtime.remember
15+
import androidx.compose.ui.Alignment
516
import androidx.compose.ui.Modifier
17+
import androidx.compose.ui.graphics.Color
18+
import androidx.compose.ui.platform.LocalContext
19+
import androidx.compose.ui.unit.dp
20+
import androidx.compose.ui.unit.sp
621
import com.utsman.osmandcompose.Marker
722
import com.utsman.osmandcompose.OpenStreetMap
823
import com.utsman.osmandcompose.rememberCameraState
924
import com.utsman.osmandcompose.rememberMarkerState
1025

1126
@Composable
1227
fun MarkerPage() {
28+
val context = LocalContext.current
29+
1330
val cameraState = rememberCameraState {
1431
geoPoint = Coordinates.depok
1532
zoom = 12.0
1633
}
1734

1835
val depokMarkerState = rememberMarkerState(
19-
geoPoint = Coordinates.depok
36+
geoPoint = Coordinates.depok,
37+
rotation = 90f
2038
)
2139

40+
val depokIcon: Drawable? by remember {
41+
mutableStateOf(context.getDrawable(R.drawable.round_eject_24))
42+
}
43+
2244
OpenStreetMap(
2345
modifier = Modifier.fillMaxSize(),
2446
cameraState = cameraState
2547
) {
2648
Marker(
27-
state = depokMarkerState
28-
)
49+
state = depokMarkerState,
50+
icon = depokIcon,
51+
title = "Depok",
52+
snippet = "Jawa barat"
53+
) {
54+
Column(
55+
modifier = Modifier
56+
.size(100.dp)
57+
.background(color = Color.Gray, shape = RoundedCornerShape(7.dp)),
58+
verticalArrangement = Arrangement.Center,
59+
horizontalAlignment = Alignment.CenterHorizontally
60+
) {
61+
Text(text = it.title)
62+
Text(text = it.snippet, fontSize = 10.sp)
63+
}
64+
}
2965
}
3066
}

Diff for: app/src/main/java/com/utsman/osmapp/PolygonPage.kt

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.utsman.osmapp
2+
3+
import androidx.compose.foundation.layout.fillMaxSize
4+
import androidx.compose.runtime.Composable
5+
import androidx.compose.runtime.remember
6+
import androidx.compose.ui.Modifier
7+
import androidx.compose.ui.graphics.Color
8+
import com.utsman.osmandcompose.OpenStreetMap
9+
import com.utsman.osmandcompose.Polygon
10+
import com.utsman.osmandcompose.Polyline
11+
import com.utsman.osmandcompose.PolylineCap
12+
import com.utsman.osmandcompose.rememberCameraState
13+
14+
@Composable
15+
fun PolygonPage() {
16+
17+
val cameraState = rememberCameraState {
18+
geoPoint = Coordinates.depok
19+
zoom = 12.0
20+
}
21+
22+
val geoPoint = remember {
23+
listOf(Coordinates.bekasi, Coordinates.depok, Coordinates.tangerang)
24+
}
25+
26+
OpenStreetMap(
27+
modifier = Modifier.fillMaxSize(),
28+
cameraState = cameraState
29+
) {
30+
Polygon(
31+
geoPoints = geoPoint,
32+
color = Color.Red,
33+
width = 18f,
34+
onPolygonLoaded = { outlinePaint, fillPaint ->
35+
36+
}
37+
)
38+
}
39+
}

Diff for: app/src/main/java/com/utsman/osmapp/PolylinePage.kt

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.utsman.osmapp
2+
3+
import android.graphics.BlendModeColorFilter
4+
import android.graphics.PorterDuff
5+
import android.graphics.PorterDuffColorFilter
6+
import androidx.compose.foundation.layout.fillMaxSize
7+
import androidx.compose.runtime.Composable
8+
import androidx.compose.runtime.remember
9+
import androidx.compose.ui.Modifier
10+
import androidx.compose.ui.graphics.Color
11+
import androidx.compose.ui.graphics.toArgb
12+
import com.utsman.osmandcompose.OpenStreetMap
13+
import com.utsman.osmandcompose.Polyline
14+
import com.utsman.osmandcompose.PolylineCap
15+
import com.utsman.osmandcompose.rememberCameraState
16+
17+
@Composable
18+
fun PolylinePage() {
19+
20+
val cameraState = rememberCameraState {
21+
geoPoint = Coordinates.depok
22+
zoom = 12.0
23+
}
24+
25+
val geoPoint = remember {
26+
listOf(Coordinates.bekasi, Coordinates.depok, Coordinates.tangerang)
27+
}
28+
29+
OpenStreetMap(
30+
modifier = Modifier.fillMaxSize(),
31+
cameraState = cameraState
32+
) {
33+
Polyline(
34+
geoPoints = geoPoint,
35+
color = Color.Red,
36+
cap = PolylineCap.ROUND,
37+
width = 18f,
38+
onPolylineLoaded = { paint ->
39+
// customize here
40+
}
41+
)
42+
}
43+
}

Diff for: app/src/main/java/com/utsman/osmapp/SimplePage.kt

+35-1
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,53 @@ package com.utsman.osmapp
22

33
import androidx.compose.foundation.layout.fillMaxSize
44
import androidx.compose.runtime.Composable
5+
import androidx.compose.runtime.SideEffect
6+
import androidx.compose.runtime.getValue
7+
import androidx.compose.runtime.mutableStateOf
8+
import androidx.compose.runtime.remember
9+
import androidx.compose.runtime.setValue
510
import androidx.compose.ui.Modifier
11+
import androidx.compose.ui.platform.LocalContext
12+
import com.utsman.osmandcompose.DefaultMapProperties
13+
import com.utsman.osmandcompose.MapProperties
614
import com.utsman.osmandcompose.OpenStreetMap
15+
import com.utsman.osmandcompose.ZoomButtonVisibility
716
import com.utsman.osmandcompose.rememberCameraState
17+
import com.utsman.osmandcompose.rememberOverlayManagerState
18+
import org.osmdroid.tileprovider.tilesource.TileSourceFactory
19+
import org.osmdroid.views.overlay.CopyrightOverlay
820

921
@Composable
1022
fun SimplePage() {
23+
val context = LocalContext.current
24+
1125
val cameraState = rememberCameraState {
1226
geoPoint = Coordinates.depok
1327
zoom = 12.0
1428
}
1529

30+
var mapProperties by remember {
31+
mutableStateOf(DefaultMapProperties)
32+
}
33+
34+
val overlayManagerState = rememberOverlayManagerState()
35+
36+
SideEffect {
37+
mapProperties = mapProperties
38+
.copy(isTilesScaledToDpi = true)
39+
.copy(tileSources = TileSourceFactory.MAPNIK)
40+
.copy(isEnableRotationGesture = true)
41+
.copy(zoomButtonVisibility = ZoomButtonVisibility.NEVER)
42+
}
43+
1644
OpenStreetMap(
1745
modifier = Modifier.fillMaxSize(),
18-
cameraState = cameraState
46+
cameraState = cameraState,
47+
properties = mapProperties,
48+
overlayManagerState = overlayManagerState,
49+
onFirstLoadListener = {
50+
val copyright = CopyrightOverlay(context)
51+
overlayManagerState.overlayManager.add(copyright)
52+
}
1953
)
2054
}

Diff for: docs/getting-started.md

+7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77

88
### Dependencies
99
```groovy
10+
// origin version of osm android. You may be able to customize the version.
11+
implementation 'org.osmdroid:osmdroid-android:6.1.16'
12+
13+
// This library dependencies
1014
implementation "tech.utsmankece:osm-androd-compose:${latest_version}"
1115
```
1216

17+
## Example app
18+
For see fully example, visit [app module](https://github.com/utsmannn/osm-android-compose/tree/main/app/src/main/java/com/utsman/osmapp)
19+
1320
---

Diff for: docs/images/info-window.png

3.05 MB
Loading

Diff for: docs/images/marker-custom.png

3.22 MB
Loading

Diff for: docs/images/marker-default.png

3.22 MB
Loading

Diff for: docs/images/polygon.png

2.87 MB
Loading

Diff for: docs/images/polyline-custom-1.png

3.2 MB
Loading

Diff for: docs/images/polyline-paint.png

59.2 KB
Loading

Diff for: docs/images/polyline.png

3.22 MB
Loading

Diff for: docs/images/simple-maps.png

3.23 MB
Loading

Diff for: docs/index.md

+19-11
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
# Welcome
22

3-
For full documentation visit [mkdocs.org](https://www.mkdocs.org).
3+
The origin OpenStreetMaps Android visit [https://osmdroid.github.io/osmdroid/](https://osmdroid.github.io/osmdroid/) or [github wiki](https://github.com/osmdroid/osmdroid/wiki)
44

5-
## Commands
5+
This is a simple OpenStreetMap library for Android Compose. There are several basic functions commonly used, such as markers, polylines, and polygons. You can also add custom tiles. For more details, please refer to the sample project.
66

7-
* `mkdocs new [dir-name]` - Create a new project.
8-
* `mkdocs serve` - Start the live-reloading docs server.
9-
* `mkdocs build` - Build the documentation site.
10-
* `mkdocs -h` - Print help message and exit.
7+
## Contributing
8+
This library may not always be maintained, and I am open to anyone who wants to contribute by reporting bugs, making pull requests, or requesting new features in the future.
119

12-
## Project layout
10+
## License
11+
```
12+
Copyright 2023 Muhammad Utsman
1313
14-
mkdocs.yml # The configuration file.
15-
docs/
16-
index.md # The documentation homepage.
17-
... # Other markdown pages, images and other files.
14+
Licensed under the Apache License, Version 2.0 (the "License");
15+
you may not use this file except in compliance with the License.
16+
You may obtain a copy of the License at
17+
18+
http://www.apache.org/licenses/LICENSE-2.0
19+
20+
Unless required by applicable law or agreed to in writing, software
21+
distributed under the License is distributed on an "AS IS" BASIS,
22+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23+
See the License for the specific language governing permissions and
24+
limitations under the License.
25+
```

0 commit comments

Comments
 (0)