View on GitHub Sample viewer app

Display a web map.

Image of open map URL

Use case

For displaying web maps stored on ArcGIS Online.

How to use the sample

A web map can be selected from the drop-down list. On selection the web map displays in the map view.

How it works

  1. Create a Portal.
  2. Create a PortalItem using the Portal and the web map ID: new PortalItem(portal, ID).
  3. Create a ArcGISMap using the portal item.
  4. Set the map to the MapView.

Relevant API

  • ArcGISMap
  • MapView
  • Portal
  • PortalItem

About the data

The web maps accessed by this sample show Recent Hurricanes, Cyclones and Typhoons and Geology for United States.

Tags

portal item, web map

Sample Code

module-info.java module-info.java OpenMapURLSample.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.open_map_url {
// 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.open_map_url;
}