-
Notifications
You must be signed in to change notification settings - Fork 0
/
add_wms_cadastre
80 lines (65 loc) · 2.49 KB
/
add_wms_cadastre
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
75
76
77
78
79
80
(() => {
"use strict";
if (document.getElementById("removeApglAddCadastreWms")) {
return;
}
const formHtml = `
<div
class="card-header rounded-0 bg-primary text-white text-left py-2">
Ajout données actuelles de la cadastre
<a class="d-flex btn btn-outline-light float-right rounded-circle p-1" ">
<span id="removeApglAddCadastreWms" class="icon icon-remove"></span>
</a> </div> <div>
<label for="codeInseeForApglAddCadastreWms" style="padding:0px 5px 0px 5px">Code INSEE </label>
<input type="number" style="flex-basis:900px" id="codeInseeForApglAddCadastreWms" />
<button id="getApglCadastreWms">Charge la cadastre</button>
</div></div>`;
let formEl = document.createElement("div");
formEl.style.fontFamily = '"News Cycle","Arial Narrow Bold",sans-serif';
formEl.classList.add("window");
formEl.classList.add("active");
formEl.innerHTML = formHtml;
formEl.style.position = "relative";
formEl.style.width = "400px";
document.getElementById("fond_isigeo").appendChild(formEl);
const closeX = document.getElementById("removeApglAddCadastreWms");
const loadButton = document.getElementById("getApglCadastreWms");
loadButton.addEventListener("click", loadWms);
const changeMapButton = document.querySelector("#cartes");
changeMapButton.addEventListener("click", closeAll, true);
var wmsLayer;
function loadWms(e) {
e.preventDefault();
if (wmsLayer) {
resetLayer();
}
const codeInsee = document.getElementById(
"codeInseeForApglAddCadastreWms"
).value;
wmsLayer = new ol.layer.Image({
source: new ol.source.ImageWMS({
url: "https://inspire.cadastre.gouv.fr/scpc/" + codeInsee + ".wms?",
params: {
LAYERS:
"AMORCES_CAD,LIEUDIT,CP.CadastralParcel,SUBFISCAL,CLOTURE,DETAIL_TOPO,HYDRO,VOIE_COMMUNICATION,BU.Building,BORNE_REPERE",
},
ratio: 1,
}),
zIndex: 1000,
});
wmsLayer.set("name", "ApglAddedCadastreWms");
const len = Viewer.map.getLayers().length;
Viewer.map.getLayers().insertAt(len, wmsLayer);
}
function resetLayer() {
Viewer.map.removeLayer(wmsLayer);
wmsLayer = null;
}
function closeAll() {
changeMapButton.removeEventListener("click", closeAll, true);
resetLayer();
document.getElementById("fond_isigeo").removeChild(formEl);
formEl = null;
}
closeX.addEventListener("click", closeAll);
})();