Hey I'm simply looking to load a map and pan/zoom to a feature.
Here is the actual page. https://data.orangeville.ca/Apps/CrossingGuards/index.html?objectid=1
I'm looking for help to get the inline map to 'goto' or pan and zoom a feature based on object id
I'm getting the objectid from a url parameter using
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : sParameterName[1];
}
}
};
and calling it using >>> getUrlParameter('objectid')
also the map has 4 layers, the one to search is layer 3 of 4 called 'Crossing Guards VIEW'
here is my codepen code just for the map for testing, with the api key removed...
<!--
To run this demo, you need to replace 'YOUR_API_KEY' with an API key from the ArcGIS Developer dashboard.
Sign up for a free account and get an API key.
https://developers.arcgis.com/documentation/mapping-apis-and-services/get-started/
--><html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>ArcGIS API for JavaScript Tutorials: 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.21/esri/themes/light/main.css">
<script src="https://js.arcgis.com/4.21/"></script>
<script>
require(["esri/config","esri/WebMap", "esri/views/MapView","esri/widgets/ScaleBar","esri/widgets/Legend"], function (esriConfig,WebMap, MapView, ScaleBar, Legend) {
esriConfig.apiKey = "API_KEY_HERE";
const webmap = new WebMap({
portalItem: {
id: "4170f5e65bd8409896a906264e4c2c87"
}
});
const view = new MapView({
map: webmap,
container: "viewDiv" // Div element
});
const scalebar = new ScaleBar({
view: view
});
view.ui.add(scalebar, "bottom-left");
var parcelExtent = response.features[0].geometry.extent.clone().expand(0.5);
view.goTo(parcelExtent);
});
</script>
</head>
<body>
<div id="viewDiv"></div>
</body>
</html>
thanks for any assistance