์ด ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ Jetpack Compose์์ ์ฌ์ฉํ ์ ์๋ ๋ค์ด๋ฒ ์ง๋ API๋ฅผ ์ ๊ณตํฉ๋๋ค.
์ด ์ ์ฅ์์๋ ์ํ ์ฑ์ด ํฌํจ๋์ด ์์ต๋๋ค. ์คํํ๋ ค๋ฉด ๋ค์์ ์ํํด์ผ ํฉ๋๋ค.
- NAVER Map Android SDK Demo ๋ ํฌ์งํฐ๋ฆฌ์ How To Run์ ์ฐธ๊ณ ํ์ฌ, ํด๋ผ์ด์ธํธ ID๋ฅผ ๋ฐ๊ธ๋ฐ์ต๋๋ค.
client_id.xml
์naver_map_sdk_client_id
์ ๋ฐ๊ธ๋ฐ์ ํด๋ผ์ด์ธํธ ID๋ฅผ ์ ๋ ฅํฉ๋๋ค.- ๋น๋ํ๊ณ ์คํํฉ๋๋ค.
Compose 1.1 (1.1.x) | |
Compose 1.2 (1.2.x) |
repositories {
mavenCentral()
}
dependencies {
implementation 'io.github.fornewid:naver-map-compose:<version>'
// NAVER Map Android SDK ์ต์ ๋ฒ์ ๋ ํฌํจํด์ผ ํฉ๋๋ค.
implementation 'com.naver.maps:map-sdk:3.15.0'
// FusedLocationSource๋ฅผ ์ฌ์ฉํ๋ ค๋ฉด play-services-location ์์กด์ฑ๋ ์ถ๊ฐํด์ผ ํฉ๋๋ค.
implementation 'com.google.android.gms:play-services-location:16.0.0'
}
NaverMap(
modifier = Modifier.fillMaxSize()
)
์ง๋๋ MapProperties
์ MapUiSettings
๊ฐ์ฒด๋ฅผ NaverMap
composable์ ์ ๋ฌํ์ฌ ๊ตฌ์ฑํ ์ ์์ต๋๋ค.
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
๋ฅผ ํตํด ์นด๋ฉ๋ผ ๋ณ๊ฒฝ์ ๊ด์ฐฐํ๊ณ ์ ์ดํ ์ ์์ต๋๋ค.
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์ ์ถ๊ฐํ๋ฉด ๋ฉ๋๋ค.
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
Marker
MultipartPathOverlay
PathOverlay
PolygonOverlay
PolylineOverlay
- ์ค๋ฅ๋ฅผ ๋ฐ๊ฒฌํ๊ฑฐ๋ ๊ถ๊ธํ ์ ์ด ์๋ค๋ฉด ์ด์๋ฅผ ๋ฑ๋กํด์ฃผ์ธ์.
- ์๋ก์ด ๊ธฐ๋ฅ์ ์ถ๊ฐํ๊ณ ์ถ๋ค๋ฉด GitHub Issues๋ฅผ ํตํด ์ง์ ๊ฐ๋ฅ ์ฌ๋ถ๋ฅผ ํ์ธํด์ผ ํฉ๋๋ค.
Copyright 2022 SOUP
Licensed 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 at
http://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.