I am trying to use the search tool but it keeps saying that There were no results found for "Seattle".
this is the code i am using on codepen.
<html>
<head>
<meta charset = "UTF-8"/>
<meta name = "viewport" content ="Initial-sacale = 1, maximum-sacale = 1, user-scalable = no">
<title> Display a Map </title>
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<link rel = "stylesheet" href = "https://js.arcgis.com/4.19/esri/themes/light/main.css">
<script src="https://js.arcgis.com/4.19/">
</script>
<script> require(["esri/config",
"esri/Map",
"esri/views/MapView",
"esri/widgets/BasemapToggle",
"esri/widgets/BasemapGallery", "esri/widgets/Search"],
function (esriConfig,
Map,
MapView,
BasemapToggle,
BasemapGallery,
Search)
{ esriConfig.apiKey = "API-KEY";
const map = new Map
({
basemap: "arcgis-navigation" });
const view = new MapView({
map: map,
center: [-118.805, 34.027],
// Longitude, latitude
zoom: 13,
// Zoom level
container: "viewDiv"
// Div element
});
const search = new Search({ //Add Search widget
view: view
});
view.ui.add(search, "top-right");
const basemapGallery = new BasemapGallery({
view: view,
source: {
query: {
title: '"World Basemaps for Developers" AND owner:esri'
}
}
}); view.ui.add(basemapGallery,"bottom-right");
const basemapToggle = new BasemapToggle({
view: view,
nextBasemap: "arcgis-imagery"
});
view.ui.add(basemapToggle,"bottom-right");
});
</script>
</head>
<body>
<div id="viewDiv"></div>
</body>
</html>
It seems that simply removing the apiKey and logging in manually allows the search widget to work normally. I'm not sure why this is happening. Hopefully someone else has an idea.
EDIT:
That apiKey is supposed to be private so I recommend redacting that.