Skip to content

bsscco/naver-map-compose

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

29 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

NAVER Map Compose ๐Ÿ—บ

์ด ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋Š” Jetpack Compose์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๋„ค์ด๋ฒ„ ์ง€๋„ API๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

Sample App

์ด ์ €์žฅ์†Œ์—๋Š” ์ƒ˜ํ”Œ ์•ฑ์ด ํฌํ•จ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ์‹คํ–‰ํ•˜๋ ค๋ฉด ๋‹ค์Œ์„ ์ˆ˜ํ–‰ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

  1. NAVER Map Android SDK Demo ๋ ˆํฌ์ง€ํ„ฐ๋ฆฌ์˜ How To Run์„ ์ฐธ๊ณ ํ•˜์—ฌ, ํด๋ผ์ด์–ธํŠธ ID๋ฅผ ๋ฐœ๊ธ‰๋ฐ›์Šต๋‹ˆ๋‹ค.
  2. client_id.xml์˜ naver_map_sdk_client_id์— ๋ฐœ๊ธ‰๋ฐ›์€ ํด๋ผ์ด์–ธํŠธ ID๋ฅผ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค.
  3. ๋นŒ๋“œํ•˜๊ณ  ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.

Download

Compose 1.1 (1.1.x)Maven Central
Compose 1.2 (1.2.x)Maven Central
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'
}

Usage

์ง€๋„ ์ถ”๊ฐ€ํ•˜๊ธฐ

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

Contributions

  • ์˜ค๋ฅ˜๋ฅผ ๋ฐœ๊ฒฌํ•˜๊ฑฐ๋‚˜ ๊ถ๊ธˆํ•œ ์ ์ด ์žˆ๋‹ค๋ฉด ์ด์Šˆ๋ฅผ ๋“ฑ๋กํ•ด์ฃผ์„ธ์š”.
  • ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ์„ ์ถ”๊ฐ€ํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด GitHub Issues๋ฅผ ํ†ตํ•ด ์ง€์› ๊ฐ€๋Šฅ ์—ฌ๋ถ€๋ฅผ ํ™•์ธํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

License

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.

About

NAVER Map Android SDK for Jetpack Compose ๐Ÿ—บ

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Kotlin 99.2%
  • Shell 0.8%