Hi
I have seen a couple of similar questions but can't seem to get the answers to fit mine, I have to admit I am new to this and this is the first map I have created this way so apologies if this is basic stuff (I have training booked in).
I have built a map which uses some data, filters it and zooms to those records when loaded. I want the filter term to be controlled by a URL parameter, so if go to www.mysite.com?filter=AreaA it applies that, filters and zooms. The code I have so far is:
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
<title>DH Test Map</title>
<style>
html, body, #viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<link rel="stylesheet" href="https://js.arcgis.com/4.14/esri/themes/light/main.css">
<script src="https://js.arcgis.com/4.14/"></script>
<script>
require([
"esri/WebMap",
"esri/views/MapView",
"esri/layers/FeatureLayer",
"esri/core/urlUtils",
"esri/tasks/support/Query"
], function(WebMap, MapView, FeatureLayer, urlUtils, Query) {
var impactedPropertiesLayer = new FeatureLayer({
url: "https://MYARCGISSERVER/arcgis/rest/services/Test/IMAffectProperties/MapServer/0",
definitionExpression: "Locality='AreaA'", ***<this is where the filter is hardcoded at the moment***
popupTemplate: { title: "{UPRN}", content: "{ADDRESS}"},
});
impactedPropertiesLayer.when(function() {
return impactedPropertiesLayer.queryExtent();
}).then(function(response) {
view.goTo(response.extent);
});
var webmap = new WebMap({
portalItem: {
id: "**PortalID of my base maps redacted**"
}
});
var view = new MapView({
container: "viewDiv",
map: webmap
});
webmap.add(impactedPropertiesLayer);
});
</script>
</head>
<body>
<div id="viewDiv"></div>
</body>
</html>