Get Started

In order to use the NAVER Maps SDK, you need to get a Client ID from NAVER CLOUD PLATFORM and set it for the SDK.

Get Client ID

Follow the procedure below to register an application and get a Client ID:

  1. Go to AI·Application Service > AI·NAVER API > Application in your web console and register an application.
  2. Check your Client ID by selecting the application registered in AI·Application Service > AI·NAVER API > Application.
  3. Click Edit of the application to make sure that Mobile Dynamic Map is selected. If it is not selected, an authentication failure error (429) occurs.

Refer to How to Use Application for details.

Add dependencies

You can get the NAVER Maps SDK from Maven repository of https://repository.map.naver.com/archive/maven. Add repository settings to build.gradle of your root project.

The following code example shows how to add repository settings.

allprojects {
    repositories {
        google()
        mavenCentral()
        maven {
            url 'https://repository.map.naver.com/archive/maven'
        }
    }
}

Groovy

allprojects {
    repositories {
        google()
        mavenCentral()
        maven {
            url 'https://repository.map.naver.com/archive/maven'
        }
    }
}

Kotlin

allprojects {
    repositories {
        google()
        mavenCentral()
        maven("https://repository.map.naver.com/archive/maven")
    }
}

Declare dependencies for the NAVER Maps SDK in build.gradle of your app module.

The following code example shows how to declare dependencies for the SDK.

dependencies {
    // NAVER Map SDK
    implementation 'com.naver.maps:map-sdk:3.18.0'
}

Groovy

dependencies {
    // NAVER Map SDK
    implementation 'com.naver.maps:map-sdk:3.18.0'
}

Kotlin

dependencies {
    // NAVER Map SDK
    implementation("com.naver.maps:map-sdk:3.18.0")
}

Set Client ID

Set your Client ID in the SDK to use the Maps API. You can set your Client ID in the following two different ways.

Set your Client ID in AndroidManifest.xml

You can set your Client ID by using <meta-data> in AndroidManifest.xml. Add a <meta-data> element under the <application>, and set name to com.naver.maps.map.CLIENT_ID and value to your Client ID.

The following code example shows how to set a Client ID in AndroidManifext.xml.

<manifest>
    <application>
        <meta-data
            android:name="com.naver.maps.map.CLIENT_ID"
            android:value="YOUR_CLIENT_ID_HERE" />
    </application>
</manifest>

For clients for public institutions, add an additional <meta-data> element, in which name is com.naver.maps.map.CLIENT_TYPE and value is gov.

The following code example shows how to set a client for public institutions in AndroidManifext.xml.

<manifest>
    <application>
        <meta-data
            android:name="com.naver.maps.map.CLIENT_ID"
            android:value="YOUR_CLIENT_ID_HERE" />
        <meta-data
            android:name="com.naver.maps.map.CLIENT_TYPE"
            android:value="gov" />
    </application>
</manifest>

Set your Client ID by making an API call

Instead of editing AndroidManifest.xml, you can set your Client ID by making an API call. Call NaverMapSdk.setClient() in onCreate() of Application to set NaverCloudPlatformClient. As NaverMapSdk is a singleton class, you should call getInstance() to get an instance.

The following code example shows how to set a Client ID by calling the API.

public class YourApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        NaverMapSdk.getInstance(this).setClient(
           new NaverMapSdk.NaverCloudPlatformClient("YOUR_CLIENT_ID_HERE"));
    }
}

Java

public class YourApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        NaverMapSdk.getInstance(this).setClient(
           new NaverMapSdk.NaverCloudPlatformClient("YOUR_CLIENT_ID_HERE"));
    }
}

Kotlin

class YourApplication : Application() {
    fun onCreate() {
        super.onCreate()
        NaverMapSdk.getInstance(this).client =
                NaverMapSdk.NaverCloudPlatformClient("YOUR_CLIENT_ID_HERE")
    }
}

For clients for public institutions, use NaverCloudPlatformGovClient, instead of NaverCloudPlatformClient.

The following code example shows how to set a client for public institutions by calling the API.

public class YourApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        NaverMapSdk.getInstance(this).setClient(
           new NaverMapSdk.NaverCloudPlatformGovClient("YOUR_CLIENT_ID_HERE"));
    }
}

Java

public class YourApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        NaverMapSdk.getInstance(this).setClient(
           new NaverMapSdk.NaverCloudPlatformGovClient("YOUR_CLIENT_ID_HERE"));
    }
}

Kotlin

class YourApplication : Application() {
    fun onCreate() {
        super.onCreate()
        NaverMapSdk.getInstance(this).client =
                NaverMapSdk.NaverCloudPlatformGovClient("YOUR_CLIENT_ID_HERE")
    }
}

Display maps

Set your Client ID and add a MapFragment to your app’s layout, and a map is displayed on your app screen.

The following code example adds a MapFragment in the <FragmentContainerView> element to the XML layout to display a map.

<androidx.fragment.app.FragmentContainerView
    android:id="@+id/map_fragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:name="com.naver.maps.map.MapFragment" />

Authentication failure handling

If the Client ID or type you set is invalid or your quota limit is exceeded, a map is not displayed, and an authentication error message is displayed as a toast and in Logcat. You can get the authentication failure event by adding OnAuthFailedListener to the NaverMapSdk.onAuthFailedListener property. Once the listener is added, the onAuthFailed() callback method is called, instead of displaying a toast message, when authentication fails.

The authentication failure event occurs only when authentication failure is clearly verified. Accordingly, this event does not occur when there is no Internet connection. In such cases, the SDK loads the map with cached data and attempts authentication when an Internet connection becomes available; if the authentication attempt fails, then the event occurs.

The exception parameter passed to onAuthFailed() shows an authentication failure reason. You can find the reason why authentication fails, with the exception type and errorCode property. The following table shows the error codes you can frequently encounter.

errorCode Exception type Description
401 UnauthorizedClientException - Invalid Client ID.
- Invalid client type.
- Wrong app package name has been registered in the console.
429 QuotaExceededException - The Maps service was not selected in the console.
- Quota limit has been exceeded.
800 ClientUnspecifiedException Client ID was not set.

An AuthFailedException occurs if authentication fails for other reasons.

results matching ""

    No results matching ""