目录

MapsInitializer

Class Info

public final class MapsInitializer

Final class that extends Object. To use certain functions before obtaining a map, use this class to initialize the Map SDK.

Public Method Summary

Qualifier and Type

Method Name and Description

static synchronized void

initialize(Context context)

Initializes the Map SDK so that its classes are ready for use.

static synchronized void

initialize(Context context, String routePolicy)

Initializes the Map SDK. You can set the data routing location. The options for routePolicy are CN (China), DE (Germany), SG (Singapore), and RU (Russia).

static void

setAccessToken(String accessToken)

Sets the access token of the Map SDK.

static void

setApiKey(String apiKey)

Sets the API key of the Map SDK.

Public Methods

[h2]initialize

Method

public static synchronized void initialize(Context context)

Initializes the Map SDK so that its classes are ready for use.

Parameters

Name

Description

context

Context required for obtaining necessary SDK resources. This parameter cannot be null.

[h2]initialize

Method

public static synchronized void initialize(Context context, String routePolicy)

Initializes the Map SDK. You can set the data routing location.

Parameters

Name

Description

context

Context required for obtaining necessary SDK resources. This parameter cannot be null.

routePolicy

Data routing location.

The options are CN (China), DE (Germany), SG (Singapore), and RU (Russia).

[h2]setAccessToken

Method

public static void setAccessToken(String accessToken)

Sets the access token of the Map SDK.

NOTE:
  • This method is applicable to the enhanced Map SDK. Do not use it in the basic Map SDK.
  • If both the API key and access token are set, the access token will be used for authentication.

Parameters

Name

Description

accessToken

Access token.

[h2]setApiKey

Method

public static void setApiKey(String apiKey)

Sets the API key of the Map SDK.

NOTE:
  • This method does not need to be called if the api_key field in the agconnect-services.json file already specifies an API key.
  • If an API key is set using setApiKey and the agconnect-services.json file also has an API key, the API key set using setApiKey takes precedence.

Parameters

Name

Description

apiKey

API key.