Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fornewid/naver-map-compose
NAVER Map Android SDK for Jetpack Compose ๐บ
https://github.com/fornewid/naver-map-compose
android-library jetpack-compose naver-map
Last synced: 1 day ago
JSON representation
NAVER Map Android SDK for Jetpack Compose ๐บ
- Host: GitHub
- URL: https://github.com/fornewid/naver-map-compose
- Owner: fornewid
- License: apache-2.0
- Created: 2022-05-14T12:06:10.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-28T13:55:01.000Z (2 months ago)
- Last Synced: 2025-01-29T03:46:09.723Z (9 days ago)
- Topics: android-library, jetpack-compose, naver-map
- Language: Kotlin
- Homepage: https://fornewid.github.io/naver-map-compose/
- Size: 3.31 MB
- Stars: 136
- Watchers: 3
- Forks: 8
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# NAVER Map Compose ๐บ
์ด ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ [Jetpack Compose][compose]์์ ์ฌ์ฉํ ์ ์๋ [๋ค์ด๋ฒ ์ง๋][naver-map] API๋ฅผ ์ ๊ณตํฉ๋๋ค.
## Sample App
์ด ์ ์ฅ์์๋ ์ํ ์ฑ์ด ํฌํจ๋์ด ์์ต๋๋ค.
์คํํ๋ ค๋ฉด ๋ค์์ ์ํํด์ผ ํฉ๋๋ค.1. [NAVER Map Android SDK Demo](https://github.com/navermaps/android-map-sdk) ๋ ํฌ์งํฐ๋ฆฌ์ [How To Run](https://github.com/navermaps/android-map-sdk#how-to-run)์ ์ฐธ๊ณ ํ์ฌ, ํด๋ผ์ด์ธํธ ID๋ฅผ ๋ฐ๊ธ๋ฐ์ต๋๋ค.
2. [`client_id.xml`](app/src/main/res/values/client_id.xml)์ `naver_map_sdk_client_id`์ ๋ฐ๊ธ๋ฐ์ ํด๋ผ์ด์ธํธ ID๋ฅผ ์ ๋ ฅํฉ๋๋ค.
3. ๋น๋ํ๊ณ ์คํํฉ๋๋ค.## Download
### naver-map-compose:
Compose 1.1 (1.1.x)![]()
Compose 1.2 (1.2.x)![]()
Compose 1.3 (1.3.x)![]()
Compose 1.4 (1.4.x)![]()
Compose 1.5 (1.5.x)![]()
Compose 1.6 (1.6.x)![]()
Compose 1.7 (1.7.x)![]()
Compose 1.8 (1.8.x)![]()
### naver-map-location:
play-services-location 16.0.0 ~![]()
play-services-location 18.0.0 ~![]()
play-services-location 21.0.1 ~![]()
```groovy
repositories {
mavenCentral()
}dependencies {
implementation 'io.github.fornewid:naver-map-compose:'// (Optional) ์์น ์ถ์ ํ๊ธฐ
// ๋ค๋ฅธ ๋ฒ์ ์ play-services-location ๊ณผ ํจ๊ป ์ฌ์ฉํ๋ ค๋ฉด ์ ์ธํด์ผ ํฉ๋๋ค.
// ์ ์ธํ์ง ์์์ ๋, ๊ธฐ๋ณธ์ผ๋ก ํฌํจ๋๋ play-services-location ๋ฒ์ ์ 16.0.0 ์ ๋๋ค.
implementation 'io.github.fornewid:naver-map-location:'
}
```### :warning: Warnings
์ด ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ ๋ด๋ถ์ ์ผ๋ก ๋ค์ด๋ฒ ์ง๋ SDK๋ฅผ ์ฌ์ฉํ๊ณ ์์ต๋๋ค.
์ด์ ๋ฐ๋ผ์ค๋ ๋ช ๊ฐ์ง ์ฃผ์์ฌํญ์ด ์์ต๋๋ค. (์ฐธ๊ณ : [๋ค์ด๋ฒ ์ง๋ ์๋๋ก์ด๋ SDK - ์์ํ๊ธฐ - ์์กด์ฑ ์ถ๊ฐ](https://navermaps.github.io/android-map-sdk/guide-ko/1.html))
1. ๋ค์ด๋ฒ ์ง๋ SDK๋ https://repository.map.naver.com/archive/maven Maven ์ ์ฅ์์์ ๋ฐฐํฌ๋ฉ๋๋ค.
๋ฐ๋ผ์ ๋ฃจํธ ํ๋ก์ ํธ์ `build.gradle`์ ์ ์ฅ์ ์ค์ ์ ์ถ๊ฐํด์ผ ํฉ๋๋ค.
```diff
allprojects {
repositories {
google()
mavenCentral()
+ maven {
+ url 'https://repository.map.naver.com/archive/maven'
+ }
// naver-map-compose 1.5.6 ๋ฒ์ ๊น์ง๋ ๋ค๋ฅธ Maven ์ ์ฅ์ ์ฃผ์๋ฅผ ์ฌ์ฉํด์ผ ํฉ๋๋ค.
// maven { url 'https://naver.jfrog.io/artifactory/maven/' }
}
}
```2. ์์ ๋ค์ด๋ฒ ์ง๋ SDK๋ [appcompat-v7](https://developer.android.com/topic/libraries/support-library/packages#v7-appcompat) 28 ๋ฒ์ ์ ์ฌ์ฉํฉ๋๋ค.
naver-map-compose 1.5.6 ๋ฒ์ ๊น์ง๋, `gradle.properties`์ Jetifier ์ต์ ์ ์ถ๊ฐํด์ค์ผ ํฉ๋๋ค.
naver-map-compose 1.5.7 ๋ฒ์ ๋ถํฐ๋ ํ์ํ์ง ์์ต๋๋ค.
```properties
android.useAndroidX=true
android.enableJetifier=true
```3. ๋ค์ด๋ฒ ์ง๋ SDK๋ ์์น ์ถ์ ๊ธฐ๋ฅ์ ์ง์ํ๋ ค๊ณ , play-services-location ๋ผ์ด๋ธ๋ฌ๋ฆฌ 16.0.0 ๋ฒ์ ์ ์ฌ์ฉํฉ๋๋ค.
์ด ๋ฒ์ ๋ณด๋ค ๋์ ๋ฒ์ ์ ์ฌ์ฉํ๊ณ ์์ผ๋ฉด, ์ปดํ์ผ ํน์ ๋ฐํ์์ ์ค๋ฅ๊ฐ ๋ฐ์ํ ์ ์์ต๋๋ค.
์ด ๋๋ play-services-location ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๋ฒ์ ๊ณผ ๊ฐ์ [naver-map-location](https://github.com/fornewid/naver-map-compose/edit/main/README.md#naver-map-location) ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ถ๊ฐ๋ก ์ ์ธํด์ผ ํฉ๋๋ค.
```diff
dependencies {
implementation 'io.github.fornewid:naver-map-compose:'
implementation 'com.google.android.gms:play-services-location:21.0.1'
+ implementation 'io.github.fornewid:naver-map-location:21.0.2'
}
```## Usage
### ์ง๋ ์ถ๊ฐํ๊ธฐ
```kotlin
NaverMap(
modifier = Modifier.fillMaxSize()
)
```### ์ง๋ ๊ตฌ์ฑํ๊ธฐ
์ง๋๋ `MapProperties`์ `MapUiSettings` ๊ฐ์ฒด๋ฅผ `NaverMap` composable์ ์ ๋ฌํ์ฌ ๊ตฌ์ฑํ ์ ์์ต๋๋ค.
```kotlin
var mapProperties by remember {
mutableStateOf(
MapProperties(maxZoom = 10.0, minZoom = 5.0)
)
}
var mapUiSettings by remember {
mutableStateOf(
MapUiSettings(isLocationButtonEnabled = false)
)
}
Box(Modifier.fillMaxSize()) {
NaverMap(properties = mapProperties, uiSettings = mapUiSettings)
Column {
Button(onClick = {
mapProperties = mapProperties.copy(
isBuildingLayerGroupEnabled = !mapProperties.isBuildingLayerGroupEnabled
)
}) {
Text(text = "Toggle isBuildingLayerGroupEnabled")
}
Button(onClick = {
mapUiSettings = mapUiSettings.copy(
isLocationButtonEnabled = !mapUiSettings.isLocationButtonEnabled
)
}) {
Text(text = "Toggle isLocationButtonEnabled")
}
}
}
```### ์ง๋์ ์นด๋ฉ๋ผ ์ ์ดํ๊ธฐ
`CameraPositionState`๋ฅผ ํตํด ์นด๋ฉ๋ผ ๋ณ๊ฒฝ์ ๊ด์ฐฐํ๊ณ ์ ์ดํ ์ ์์ต๋๋ค.
```kotlin
val seoul = LatLng(37.532600, 127.024612)
val cameraPositionState: CameraPositionState = rememberCameraPositionState {
// ์นด๋ฉ๋ผ ์ด๊ธฐ ์์น๋ฅผ ์ค์ ํฉ๋๋ค.
position = CameraPosition(seoul, 11.0)
}
Box(Modifier.fillMaxSize()) {
NaverMap(cameraPositionState = cameraPositionState)
Button(onClick = {
// ์นด๋ฉ๋ผ๋ฅผ ์๋ก์ด ์ค ๋ ๋ฒจ๋ก ์ด๋ํฉ๋๋ค.
cameraPositionState.move(CameraUpdate.zoomIn())
}) {
Text(text = "Zoom In")
}
}
```### ์ง๋์ ๊ทธ๋ฆฌ๊ธฐ
์ง๋์ `Marker`์ฒ๋ผ Overlay๋ฅผ ์ถ๊ฐํ๋ ค๋ฉด, `NaverMap`์ content์ child composable์ ์ถ๊ฐํ๋ฉด ๋ฉ๋๋ค.
```kotlin
NaverMap {
Marker(
state = MarkerState(position = LatLng(37.532600, 127.024612)),
captionText = "Marker in Seoul"
)
Marker(
state = MarkerState(position = LatLng(37.390791, 127.096306)),
captionText = "Marker in Pangyo"
)
}
```์ ๊ณต๋๋ Overlay๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
- `ArrowheadPathOverlay`
- `CircleOverlay`
- `GroundOverlay`
- `LocationOverlay`
- `Marker`
- `MultipartPathOverlay`
- `PathOverlay`
- `PolygonOverlay`
- `PolylineOverlay`#### raw NaverMap ๊ฐ์ฒด ์ป๊ธฐ (Experimental)
ํน์ UseCase์์๋ `NaverMap` ๊ฐ์ฒด๊ฐ ํ์ํฉ๋๋ค.
์๋ฅผ ๋ค์ด, ์ด ๋ผ์ด๋ธ๋ฌ๋ฆฌ์์ ๋ง์ปค ํด๋ฌ์คํฐ๋ง์ ์์ง ์ง์๋์ง ์์ง๋ง([Issue #14](https://github.com/fornewid/naver-map-compose/issues/14) ์ฐธ์กฐ),
[์ธ๋ถ ๋ผ์ด๋ธ๋ฌ๋ฆฌ](https://github.com/ParkSangGwon/TedNaverMapClustering) ๋ฅผ ์ด์ฉํ์ฌ ํด๋ฌ์คํฐ๋ง์ ๊ตฌํํ ์ ์์ต๋๋ค.
์ด๋ ๊ฒ ๊ตฌํํ๋ ค๋ฉด `MapEffect` ํน์ `DisposableMapEffect` composable์ ์ฌ์ฉํ์ฌ ๋ค์ด๋ฒ์ง๋ SDK์ raw `NaverMap` ๊ฐ์ฒด์ ์ ๊ทผํด์ผ ํฉ๋๋ค.```kt
NaverMap(
// ...
) {
val context = LocalContext.current
var clusterManager by remember { mutableStateOf?>(null) }
DisposableMapEffect(items) { map ->
if (clusterManager == null) {
clusterManager = TedNaverClustering.with(context, map).make()
}
clusterManager?.addItems(items)
onDispose {
clusterManager?.clearItems()
}
}
}
```### ์์น ์ถ์ ํ๊ธฐ
> :warning: `play-services-location` ๋ฒ์ ์ด 16.0.0 ๋ณด๋ค ๋์ผ๋ฉด, ์ปดํ์ผ ํน์ ๋ฐํ์์ ์ค๋ฅ๊ฐ ๋ฐ์ํ ์ ์์ต๋๋ค. ([Warnings ์น์ ์ ์ฐธ๊ณ ํ์ธ์.](https://github.com/fornewid/naver-map-compose/edit/main/README.md#warning-warnings))
๊ตฌ๊ธ์์ ์ ๊ณตํ๋ [FusedLocationProviderClient](https://developers.google.com/android/reference/com/google/android/gms/location/FusedLocationProviderClient)์ ์ด์ฉํ์ฌ, ์์น๋ฅผ ์ถ์ ํ๋ ๊ธฐ๋ฅ์ ์ ๊ณตํฉ๋๋ค.
`MapProperties`์ `locationTrackingMode`๋ฅผ ์ค์ ํ์ฌ ์์น ์ถ์ ๋ชจ๋๋ฅผ ์ง์ ํ ์ ์์ต๋๋ค.
```kotlin
NaverMap(
locationSource = rememberFusedLocationSource(),
properties = MapProperties(
locationTrackingMode = LocationTrackingMode.Follow,
),
uiSettings = MapUiSettings(
isLocationButtonEnabled = true,
)
)
````LocationTrackingMode`๊ฐ `Follow` ๋๋ `Face`์ผ ๋, ๋์นจ๋ฐ ๊ธฐ๋ฅ์ ํ์ฑํํ๋ ค๋ฉด `isCompassEnabled`์ true๋ก ์ค์ ํด์ผ ํฉ๋๋ค.
```kotlin
NaverMap(
locationSource = rememberFusedLocationSource(isCompassEnabled = true),
properties = MapProperties(
locationTrackingMode = LocationTrackingMode.Face,
),
uiSettings = MapUiSettings(
isLocationButtonEnabled = true,
)
)
```## Snapshots
ํ์ฌ ๊ฐ๋ฐ ์ค์ธ ๋ฒ์ ์ ํ์ธํ๊ณ ์ถ๋ค๋ฉด [SNAPSHOT ๋ฒ์ ](https://s01.oss.sonatype.org/content/repositories/snapshots/io/github/fornewid/naver-map-compose/)์ ์ฌ์ฉํ ์ ์์ต๋๋ค.
Snapshot์ `main` branch์ ์ปค๋ฐ์ด ์ถ๊ฐ๋ ๋๋ง๋ค ์ ๋ฐ์ดํธ๋ฉ๋๋ค.
```groovy
repositories {
maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots' }
}dependencies {
// ์ ๋งํฌ์์ ์ต์ SNAPSHOT ๋ฒ์ ์ ํ์ธํ์ธ์.
classpath 'io.github.fornewid:naver-map-compose:XXX-SNAPSHOT'
}
```## Contributions
- ์ค๋ฅ๋ฅผ ๋ฐ๊ฒฌํ๊ฑฐ๋ ๊ถ๊ธํ ์ ์ด ์๋ค๋ฉด [์ด์๋ฅผ ๋ฑ๋กํด์ฃผ์ธ์.](https://github.com/fornewid/naver-map-compose/issues/new)
- ์๋ก์ด ๊ธฐ๋ฅ์ ์ถ๊ฐํ๊ณ ์ถ๋ค๋ฉด [GitHub Issues](https://github.com/fornewid/naver-map-compose/issues)๋ฅผ ํตํด ์ง์ ๊ฐ๋ฅ ์ฌ๋ถ๋ฅผ ํ์ธํด์ผ ํฉ๋๋ค.## License
```
Copyright 2022 SOUPLicensed to the Apache Software Foundation (ASF) under one or more contributor
license agreements. See the NOTICE file distributed with this work for
additional information regarding copyright ownership. The ASF licenses this
file to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License athttp://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.
```[naver-map]: https://navermaps.github.io/android-map-sdk/guide-ko/
[compose]: https://developer.android.com/jetpack/compose
[api-key]: https://navermaps.github.io/android-map-sdk/guide-ko/1.html