View on GitHub Sample viewer app

Change a map’s basemap. A basemap is beneath all layers on an ArcGISMap and is used to provide visual reference for the operational layers.

Image of change basemap

Use case

Basemaps should be selected contextually, for example, in maritime applications, it would be more appropriate to use a basemap of the world’s oceans as opposed to a basemap of the world’s streets.

How to use the sample

Select a basemap style from the list to set it to the map.

How it works

  1. Create an ArcGISMap object.
  2. Set the map to the MapView object.
  3. Choose a new basemap style with BasemapStyle and set it on the map.

Relevant API

  • ArcGISMap
  • BasemapStyle
  • MapView

Tags

basemap, map

Sample Code

module-info.java module-info.java ChangeBasemapSample.java
/*
* Copyright 2022 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.
*/
module com.esri.samples.change_basemap {
// require ArcGIS Maps SDK for Java module
requires com.esri.arcgisruntime;
// handle SLF4J http://www.slf4j.org/codes.html#StaticLoggerBinder
requires org.slf4j.nop;
// require JavaFX modules that the application uses
requires javafx.graphics;
requires javafx.controls;
exports com.esri.samples.change_basemap;
}