In this lab you will add a search widget. The widget performs context-sensitve search as you type and then it will zoom to and highlight the feature selected. You can also format the data in the popup that appears.
Click create_starter_map_3d/index.html and copy the contents to a new jsbin.com.
In JSBin
> HTML
, update the require
statement and function
definition:
require([
"esri/Map",
"esri/views/SceneView",
/*** ADD ***/
"esri/widgets/Search",
"dojo/domReady!"
], function(Map, SceneView, /*** ADD ***/ Search) {
Change the Map’s basemap
and ground
properties.
var map = new Map({
basemap: "satellite",
ground: "world-elevation"
});
Create the Search widget and add its code below SceneView
. Position the widget to the top-left
of the UI.
var searchWidget = new Search({
view: view
});
searchWidget.startup();
// Add the search widget to the top left corner of the view
view.ui.add(searchWidget, {
position: "top-left",
index: 0
});
portland
and select Portland, Oregon from the pulldown list. The app should highlight and zoom into the appropriate area, and a popup should also be displayed with related data.Your app should look something like this: