-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSelect_form_with_coded_domain_values.html
74 lines (65 loc) · 2.31 KB
/
Select_form_with_coded_domain_values.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
<title>Simple Map</title>
<link rel="stylesheet" href="https://js.arcgis.com/3.23/esri/css/esri.css">
<style>
html, body, #map {
height: 100%;
margin: 0;
padding: 0;
}
</style>
<script src="https://js.arcgis.com/3.23/"></script>
<script>
var map;
var data;
require(["esri/map",
"esri/layers/FeatureLayer",
"dojo/domReady!"],
function(Map,
FeatureLayer
) {
map = new Map("map", {
basemap: "topo",
});
data = new FeatureLayer("https://sampleserver6.arcgisonline.com/arcgis/rest/services/LocalGovernment/CitizenRequests/FeatureServer/0",{
outFields: ["*"]
});
map.addLayer(data);
//Recuperer domaine attributaire code/valeur
map.on("load", function(evt){
alert("Chargement des valeurs");
select = document.getElementById('selectElementId');
domaines=data.fields[1].domain.codedValues;
for (i = 0; i < domaines.length; i++){
var opt = document.createElement('option');
opt.value = domaines[i].code;
opt.innerHTML = domaines[i].name;
select.appendChild(opt);
};
});
//Requeter featurelayer à partir des valeurs du formulaire
dojo.connect(dojo.byId("rechercher"),"onclick", function(){
type = document.getElementById('selectElementId').value;
alert("Filtre carte avec elements de type: "+document.getElementById('selectElementId').options[document.getElementById('selectElementId').options.selectedIndex].innerHTML);
if(type=="*"){
data.setDefinitionExpression("");
}else{
data.setDefinitionExpression("requesttype ="+type);
}
});
}); //fin
</script>
</head>
<body>
<div id="form">
formulaire renseigné automatiquement avec la liste des valeurs d'un domaine attributaire :</br>
<select id="selectElementId"><option value="*" selected=1>Tous</option></select></br>
<button id="rechercher">Filtrer</button>
</div>
<div id="map"></div>
</body>
</html>