Follow these steps to migrate your existing app to use ArcGIS location services.

This information is intended for developers who have an existing app and would like to update it to use ArcGIS location services. Use the current version to ensure that you have access to the latest capabilities.

Authentication

To use any of the ArcGIS location services ArcGIS Location Services, also referred to as Location Services, are services hosted by Esri that provide geospatial functionality for developing mapping applications. They include the ArcGIS Basemap Styles service, ArcGIS Static Basemap Tiles service, ArcGIS Places service, ArcGIS Geocoding service, ArcGIS Routing service, ArcGIS GeoEnrichment service, and ArcGIS Elevation service. An ArcGIS Location Platform or ArcGIS Online account is required to use the services. Learn more , your app must provide authentication with an appropriate access token An access token is an authorization string that provides access to secure ArcGIS content, data, and services. Its capabilities are determined by the privileges it supports. It is obtained by implementing API key authentication, User authentication, or App authentication. Learn more . Access tokens define the privileges Privileges are a set of permissions assigned to ArcGIS accounts, developer credentials, and applications that grant access to secure resources and functionality in ArcGIS. Learn more available to your application. There are three types of authentication that can be used to access location services:

  • API key authentication: This type of authentication uses a long-lived access token to authenticate requests to ArcGIS location services ArcGIS Location Services, also referred to as Location Services, are services hosted by Esri that provide geospatial functionality for developing mapping applications. They include the ArcGIS Basemap Styles service, ArcGIS Static Basemap Tiles service, ArcGIS Places service, ArcGIS Geocoding service, ArcGIS Routing service, ArcGIS GeoEnrichment service, and ArcGIS Elevation service. An ArcGIS Location Platform or ArcGIS Online account is required to use the services. Learn more . For more information see the Introduction to API key authentication. Go to the Create an API key tutorial to obtain a new API Key access token using your ArcGIS Location Platform account ArcGIS Location Platform, formerly known as ArcGIS Platform, is a Platform as a Service (PaaS) product that gives developers access to location services, APIs, and tools to build mapping and spatial analysis applications. It is subscription-based and requires an ArcGIS Location Platform account. Learn more or ArcGIS Online account ArcGIS Online is a GIS mapping, analytics, data hosting, and content management software as a service (SaaS) product. It includes applications, tools, APIs, and location services for users and developers. It is subscription-based and requires an ArcGIS Online account. Learn more account. This is the recommended type of authentication for developers new to ArcGIS, or to development in general.
  • User authentication: This generates a short-lived token via OAuth credentials, authorizing your application to access ArcGIS location services ArcGIS Location Services, also referred to as Location Services, are services hosted by Esri that provide geospatial functionality for developing mapping applications. They include the ArcGIS Basemap Styles service, ArcGIS Static Basemap Tiles service, ArcGIS Places service, ArcGIS Geocoding service, ArcGIS Routing service, ArcGIS GeoEnrichment service, and ArcGIS Elevation service. An ArcGIS Location Platform or ArcGIS Online account is required to use the services. Learn more on behalf of a user logged in with an ArcGIS Location Platform An ArcGIS Location Platform account, formerly known as an ArcGIS Developer account, is an identity associated with an ArcGIS Location Platform subscription. Learn more or ArcGIS Online An ArcGIS Online account, also known as an ArcGIS Organization account, is an identity associated with an ArcGIS Online subscription. It can be used to access ArcGIS tools and develop applications with ArcGIS location services for an organization. Learn more account.
  • App authentication: This generates a short-lived token via OAuth credentials, authorizing your application to access ArcGIS location services ArcGIS Location Services, also referred to as Location Services, are services hosted by Esri that provide geospatial functionality for developing mapping applications. They include the ArcGIS Basemap Styles service, ArcGIS Static Basemap Tiles service, ArcGIS Places service, ArcGIS Geocoding service, ArcGIS Routing service, ArcGIS GeoEnrichment service, and ArcGIS Elevation service. An ArcGIS Location Platform or ArcGIS Online account is required to use the services. Learn more on your behalf.

Learn more about getting and using an access token in Security and authentication and the Display a map tutorial.

Global API key

When your app starts, you can set the api key on your ArcGISEnvironment to an API key access token An access token is an authorization string that provides access to secure ArcGIS content, data, and services. Its capabilities are determined by the privileges it supports. It is obtained by implementing API key authentication, User authentication, or App authentication. Learn more . This authorizes access to all ArcGIS location services used by your app.

MainActivity.kt
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Set the access token for ArcGIS Maps for Kotlin.
ArcGISEnvironment.apiKey = ApiKey.create("YOUR_ACCESS_TOKEN")
setContent {
SampleAppTheme {
MainScreen()
}
}
}
}

If needed, you can override this access token by explicitly setting a different access token on layers, basemaps, or any other classes that use platform location services (those that implement the ApiKeyResource interface).

Basemaps

Review the basemap styles service and the variety of basemaps available. Create a new basemap using one of the enumeration values from BasemapStyle and use it to create your ArcGISMap.

You can set an API Key access token An access token is an authorization string that provides access to secure ArcGIS content, data, and services. Its capabilities are determined by the privileges it supports. It is obtained by implementing API key authentication, User authentication, or App authentication. Learn more directly on the basemap or default to a global access token, if one is set on the ArcGISEnvironment. The API Key must have the privilege Basemap styles service enabled.

// Create a new 'topographic' basemap.
val basemap = Basemap(basemapStyle = BasemapStyle.ArcGISTopographic)
// Optionally, set a specific access token directly for the basemap.
// (Not required if an access token has been set on the ArcGISEnvironment).
basemap.apiKey = ApiKey.create("YOUR_ACCESS_TOKEN")
// Create a new map with the basemap.
val map = ArcGISMap(basemap = basemap)
MapView(
modifier = Modifier.fillMaxSize(),
arcGISMap = map
)

Geocoding

Access to the geocoding service is available using an API Key access token An access token is an authorization string that provides access to secure ArcGIS content, data, and services. Its capabilities are determined by the privileges it supports. It is obtained by implementing API key authentication, User authentication, or App authentication. Learn more , either globally for the app, or by setting it explicitly on your LocatorTask. If you are using an API key access token it must have been generated with the Geocoding privilege.

Routes and directions

Access to routing and directions APIs is unchanged with the new ArcGIS location services introduced with ArcGIS Location Platform ArcGIS Location Platform, formerly known as ArcGIS Platform, is a Platform as a Service (PaaS) product that gives developers access to location services, APIs, and tools to build mapping and spatial analysis applications. It is subscription-based and requires an ArcGIS Location Platform account. Learn more . Authentication is required to access these services, using API key authentication or user authentication. If you are using an API key access token must have been generated with the Routing privilege.

See the Find routes and directions topic for more information.

Other services

See all the Location services available.