View on GitHub Sample viewer app

Find webmap portal items by using a search term.

Image of search for webmap

Use case

Portals can contain many portal items and at times you may wish to query the portal to find what you’re looking for. In this example, we search for webmap portal items using a text search.

How to use the sample

Enter search terms into the search bar. Once the search is complete, a list is populated with the resultant webmaps. Click on a webmap to set it to the map view. Click on the “Find more results” button to add more results to the list.

How it works

  1. Create a new Portal and load it.
  2. Create new PortalQueryParameters. Set the type to PortalItem.Type.WEBMAP and add the text you want to search for.
  3. Use portal.findItemsAsync(params) to get the first set of matching items (10 by default).
  4. Get more results with portal.findItemsAsync(portalQueryResultSet.getNextQueryParameters()).

Relevant API

  • Portal
  • PortalItem
  • PortalQueryParameters
  • PortalQueryResultSet

Tags

keyword, query, search, webmap

Sample Code

module-info.java module-info.java WebmapKeywordSearchController.java WebmapKeywordSearchSample.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.webmap_keyword_search {
// 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;
requires javafx.fxml;
// make all @FXML annotated objects reflectively accessible to the javafx.fxml module
opens com.esri.samples.webmap_keyword_search to javafx.fxml;
exports com.esri.samples.webmap_keyword_search;
}