I have a script to grab the pop-up information when opened from the search bar. Only I get null results for the first opened pop-up and it's driving me crazy.
The second time a pop up everything works as expected. I just can't capture the first pop up to open.
If there is a better way to know which pop up is opened, I would love to know.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
<title>Search Widget | Sample | ArcGIS API for JavaScript 4.16</title>
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<script>
require([
"esri/Map",
"esri/views/SceneView",
"esri/widgets/Search"
], function (Map, SceneView, Search) {
var map = new Map({
basemap: "satellite",
ground: "world-elevation"
});
var view = new SceneView({
scale: 123456789,
container: "viewDiv",
map: map
});
var searchWidget = new Search({
view: view
});
//a watcher for when the pop up fires
view.popup.watch("visible", function (popUpStatusChange) {
if (popUpStatusChange == true) {
console.log('Pop-up watch has been fired')
console.log("Pop-up title is:", view.popup.title); //returns the pop up title
console.log("Pop-up content is:", view.popup.content); //returns the pop up content
}
});
view.ui.add(searchWidget, {
position: "top-right"
});
});
</script>
</head>
<body>
<div id="viewDiv"></div>
</body>
</html>