View on GitHub Sample viewer app

Access and create bookmarks on a map.

Image of manage bookmarks

Use case

Bookmarks are saved extents for a map. A tour app may save a bookmark for each site in the tour. An app may also allow users to add their own favorite places as bookmarks.

How to use the sample

The map in the sample comes pre-populated with a set of bookmarks. To access a bookmark and move to that location, click on a bookmark’s name from the list. To add a bookmark, pan and/or zoom to a new location and click on the ‘Add Bookmark’ button. Enter a unique name for the bookmark and click ok, and the bookmark will be added to the list.

How it works

  1. Instantiate a new ArcGISMap object and create a BookmarkList with ArcGISMap.getBookmarks().
  2. To create a new bookmark and add it to the bookmark list:
    • Instantiate a new Bookmark object passing in text (the name of the bookmark) and a Viewpoint as parameters.
    • Add the new bookmark to the bookmark list with BookmarkList.add(bookmark).

Relevant API

  • Bookmark
  • BookmarkList
  • Viewpoint

Tags

bookmark, extent, location, zoom

Sample Code

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