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 ArcGISRuntimeEnvironment 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.

App.java
36 collapsed lines
// Copyright 2020 Esri
// Licensed 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.
package com.example.app;
import com.esri.arcgisruntime.ArcGISRuntimeEnvironment;
import com.esri.arcgisruntime.mapping.ArcGISMap;
import com.esri.arcgisruntime.mapping.BasemapStyle;
import com.esri.arcgisruntime.mapping.Viewpoint;
import com.esri.arcgisruntime.mapping.view.MapView;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class App extends Application {
private MapView mapView;
public static void main(String[] args) {
Application.launch(args);
}
@Override
public void start(Stage stage) {
// set the title and size of the stage and show it
stage.setTitle("Display a map tutorial");
stage.setWidth(800);
stage.setHeight(700);
stage.show();
// create a JavaFX scene with a stack pane as the root node, and add it to the scene
StackPane stackPane = new StackPane();
Scene scene = new Scene(stackPane);
stage.setScene(scene);
ArcGISRuntimeEnvironment.setApiKey("YOUR_ACCESS_TOKEN");
25 collapsed lines
// create a map view to display the map and add it to the stack pane
mapView = new MapView();
stackPane.getChildren().add(mapView);
ArcGISMap map = new ArcGISMap(BasemapStyle.ARCGIS_TOPOGRAPHIC);
// set the map on the map view
mapView.setMap(map);
mapView.setViewpoint(new Viewpoint(34.02700, -118.80543, 144447.638572));
}
/**
* Stops and releases all resources used in application.
*/
@Override
public void stop() {
if (mapView != null) {
mapView.dispose();
}
}
}

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 ArcGISRuntimeEnvironment. The API Key must have the privilege Basemap styles service enabled.

// Create a new 'topographic' basemap.
Basemap basemap = new Basemap(BasemapStyle.ARCGIS_TOPOGRAPHIC);
// Optionally, set a specific access token directly for the basemap.
// (Not required if an access token has been set on the ArcGISRuntimeEnvironment).
basemap.setApiKey(yourApiKey);
// Create a new map that uses the basemap.
ArcGISMap map = new ArcGISMap(basemap);

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.