-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript.js
265 lines (233 loc) · 9.07 KB
/
script.js
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
L.MyHash = function(map, options) {
L.Hash.call(this, map, options);
};
L.MyHash.prototype = L.Util.create(L.Hash.prototype);
L.MyHash.prototype.constructor = L.MyHash;
L.Util.extend(L.MyHash.prototype, {
parseHash: function(hash) {
console.log('parseHash: ' + hash);
var parsed = L.Hash.prototype.parseHash.call(this, hash);
console.log('parseHash: ' + JSON.stringify(parsed));
return parsed;
},
formatHash: function(map) {
var formatted = L.Hash.prototype.formatHash.call(this, map);
console.log('formatHash: ' + formatted);
return formatted;
},
update: function() {
L.Hash.prototype.update.call(this);
console.log('update');
}
});
L.myHash = function(map, options) {
return new L.MyHash(map, options);
};
var map = new L.Map('map', {
center: [59.2993, 24.541],
zoom: 11
});
map.attributionControl.setPrefix('Teostus: Tormi Tabor');
var osm = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: 'Aluskaart © <a href="http://osm.org/copyright">OpenStreetMap</a>'
});
// KEMITi aluskaardid
// mustvalge aluskaart
var blacktile = L.tileLayer(
'https://gsavalik.envir.ee/geoserver/gwc/service/tms/1.0.0/baasandmed:black@EPSG:3857@png/{z}/{x}/{-y}.png', {
minZoom: 0,
maxZoom: 14,
continuousWorld: false,
noWrap: false,
attribution: 'MV aluskaart - andmed: <a href="https://www.maaamet.ee/" target="_blank" rel="noopener noreferrer">Maa-amet</a>, <a href="http://keskkonnaagentuur.ee" target="_blank" rel="noopener noreferrer">Keskkonnaregister (KAUR)</a> ning <a href="https://www.openstreetmap.org/copyright" target="_blank" rel="noopener noreferrer">OpenStreetMap contributors</a>; teostus <a href="https://github.com/e-gov/kem-gsavalik/blob/master/LICENSE" target="_blank" rel="noopener noreferrer">KEMIT ja kaastöölised</a>'
}
);
var blackwms = L.tileLayer.wms(
'https://gsavalik.envir.ee/geoserver/baasandmed/ows', {
layers: 'baasandmed:black',
transparent: true,
format: 'image/png',
minZoom: 15,
maxZoom: 20,
version: '1.1.1',
crs: L.CRS.EPSG4326,
attribution: 'MV aluskaart - andmed: <a href="https://www.maaamet.ee/" target="_blank" rel="noopener noreferrer">Maa-amet</a>, <a href="http://keskkonnaagentuur.ee" target="_blank" rel="noopener noreferrer">Keskkonnaregister (KAUR)</a> ning <a href="https://www.openstreetmap.org/copyright" target="_blank" rel="noopener noreferrer">OpenStreetMap contributors</a>; teostus <a href="https://github.com/e-gov/kem-gsavalik/blob/master/LICENSE" target="_blank" rel="noopener noreferrer">KEMIT ja kaastöölised</a>'
}
);
var black = L.layerGroup([blacktile, blackwms]);
var pohi = L.tileLayer.wms("https://kaart.maaamet.ee/wms/alus-geo?", {
format: 'image/png',
transparent: true,
minZoom: 15,
layers: 'pohi_vv',
crs: L.CRS.EPSG4326,
attribution: 'Põhikaart © <a href="https://geoportaal.maaamet.ee/est/Teenused/Avalik-WMS-teenus-p65.html" target="_blank">Maa-amet</a>'
});
// var orto = L.tileLayer.wms("https://kaart.maaamet.ee/wms/alus-geo?", {
// format: 'image/png',
// transparent: true,
// layers: 'EESTIFOTO',
// crs: L.CRS.EPSG4326,
// attribution: 'Ortofoto © <a href="http://geoportaal.maaamet.ee/est/Teenused/Avalik-WMS-teenus-p65.html" target="_blank">Maa-amet</a>'
// });
var orto = new L.TileLayer('https://tiles.maaamet.ee/tm/tms/1.0.0/foto@GMC/{z}/{x}/{-y}.png', {
attribution: 'Ortofoto © <a href="https://www.maaamet.ee/" target="_blank" rel="noopener noreferrer">Maa-Amet</a>'
}).addTo(map);
// var hybriid = L.tileLayer.wms("https://kaart.maaamet.ee/wms/alus-geo?", {
// format: 'image/png',
// transparent: true,
// layers: 'HYBRID',
// crs: L.CRS.EPSG4326
// });
var hybriid = new L.TileLayer('https://tiles.maaamet.ee/tm/tms/1.0.0/hybriid@GMC/{z}/{x}/{-y}.png', {}).addTo(map);
var kataster = L.tileLayer.wms("https://kaart.maaamet.ee/wms/alus-geo?", {
format: 'image/png',
transparent: true,
minZoom: 15,
layers: 'TOPOYKSUS_6569',
crs: L.CRS.EPSG4326
});
var puurkaev = L.tileLayer(
'https://gsavalik.envir.ee/geoserver/gwc/service/tms/1.0.0/eelis:kr_puurk_sankaitseala@EPSG:3857@png/{z}/{x}/{-y}.png', {
minZoom: 0,
maxZoom: 14,
continuousWorld: false,
noWrap: false,
attribution: "Puurkaevud: EELIS - <a href=\"http://keskkonnaagentuur.ee\" target=\"_blank\" rel=\"noopener noreferrer\">Keskkonnaagentuur</a>",
}
);
var sauevyp = L.tileLayer('https://mapwarper.net/maps/tile/17658/{z}/{x}/{y}.png', {
attribution: '<a href="https://sauevald.ee/uldplaneeringud" target="_blank">Saue valla üldplaneering 2016</a>',
opacity: 0.8
}).addTo(map);
var sauelyp = L.tileLayer('https://mapwarper.net/maps/tile/22978/{z}/{x}/{y}.png', {
attribution: '<a href="https://sauevald.ee/uldplaneeringud" target="_blank">Saue linna üldplaneering 2010</a>'
}).addTo(map);
var kernuyp = L.tileLayer('https://mapwarper.net/layers/tile/667/{z}/{x}/{y}.png', {
attribution: '<a href="https://sauevald.ee/uldplaneeringud" target="_blank">Kernu valla üldplaneering 2006</a>'
}).addTo(map);
var nissiyp = L.tileLayer('https://mapwarper.net/maps/tile/17668/{z}/{x}/{y}.png', {
attribution: '<a href="https://sauevald.ee/uldplaneeringud" target="_blank">Nissi valla üldplaneering 2014</a>'
}).addTo(map);
var harjump = L.tileLayer('https://mapwarper.net/maps/tile/36628/{z}/{x}/{y}.png', {
attribution: '<a href="https://maakonnaplaneering.ee/harju-maakonnaplaneering" target="_blank">Harju maakonnaplaneering 2030+. Tehnilised võrgustikud</a>'
});
var harjumpbase = L.tileLayer('https://mapwarper.net/maps/tile/36628/{z}/{x}/{y}.png', {
attribution: '<a href="https://maakonnaplaneering.ee/harju-maakonnaplaneering" target="_blank">Harju maakonnaplaneering 2030+. Tehnilised võrgustikud</a>'
});
var saueyp2019 = L.tileLayer('https://mapwarper.net/maps/tile/46458/{z}/{x}/{y}.png', {
attribution: '<a href="http://sauevald.ee/koostatav-uldplaneering" target="_blank">Saue valla uue üldplaneeringu koondjoonis, 20.03.2020</a>'
});
var saueyp2019base = L.tileLayer('https://mapwarper.net/maps/tile/46458/{z}/{x}/{y}.png', {
attribution: '<a href="http://sauevald.ee/koostatav-uldplaneering" target="_blank">Saue valla uue üldplaneeringu koondjoonis, 20.03.2020</a>'
});
var sakuyp2009 = L.tileLayer('https://mapwarper.net/maps/tile/17673/{z}/{x}/{y}.png', {
attribution: '<a href="https://www.sakuvald.ee/et/uldplaneering" target="_blank">Saku valla 2009.a üldplaneering</a>'
});
var laagri2009 = L.tileLayer('https://mapwarper.net/maps/tile/2450/{z}/{x}/{y}.png', {
attribution: 'K-Projekti 2009.a Juuliku-Tabasalu eelprojekt'
});
var laagri2020 = L.tileLayer('https://mapwarper.net/maps/tile/46254/{z}/{x}/{y}.png', {
attribution: 'Selektor Projekti 2020.a Juuliku-Tabasalu eskiis Laagri viadukti osas'
});
L.control.locate({
strings: {
title: "Näita minu asukohta"
}
}).addTo(map);
function formatJSON(rawjson) {
var json = {},
res, key, loc = [];
res = rawjson.addresses;
for (var i in res) {
key = res[i].ipikkaadress;
loc = L.latLng(res[i].viitepunkt_b, res[i].viitepunkt_l);
json[key] = loc;
}
return json;
};
map.addControl(new L.Control.Search({
url: 'https://inaadress.maaamet.ee/inaadress/gazetteer?features=KATASTRIYKSUS&address={s}',
jsonpParam: 'callback',
formatData: formatJSON,
textPlaceholder: 'Otsi katastriüksust aadressi/tunnuse järgi',
marker: L.circleMarker([0, 0], {
radius: 20,
color: "#ffcc00"
}),
autoCollapse: true,
autoType: false,
minLength: 2,
zoom: 18
}));
var allMapLayers = {
'osm': osm,
'pohi': pohi,
'orto': orto,
'harjumpbase': harjumpbase,
'hybriid': hybriid,
'kataster': kataster,
'sauevyp': sauevyp,
'sauelyp': sauelyp,
'kernuyp': kernuyp,
'nissiyp': nissiyp,
'harjump': harjump,
'sakuyp2009': sakuyp2009,
'laagri2009': laagri2009,
'laagri2020': laagri2020
};
L.control.layers({
'OpenStreetMap': osm,
'Põhikaart (z15+)': pohi,
'Ortofoto': orto,
'Harju MP 2035+': harjumpbase
}, {
'Hübriidkaart': hybriid,
'Katastripiirid (z15+)': kataster,
'Saue valla ÜP': sauevyp,
'Saue linna ÜP': sauelyp,
'Kernu valla ÜP': kernuyp,
'Nissi valla ÜP': nissiyp,
'Harju MP 2035+': harjump,
'Saku ÜP 2009': sakuyp2009,
'Laagri ms 2009': laagri2009,
'Laagri ms 2020': laagri2020
}).addTo(map);
$(function() {
$("#slider").slider({
orientation: "vertical",
range: "min",
min: 0,
max: 100,
value: 80,
slide: function(e, ui) {
sauevyp.setOpacity(ui.value / 100);
sauelyp.setOpacity(ui.value / 100);
kernuyp.setOpacity(ui.value / 100);
nissiyp.setOpacity(ui.value / 100);
harjump.setOpacity(ui.value / 100);
sakuyp2009.setOpacity(ui.value / 100);
laagri2009.setOpacity(ui.value / 100);
laagri2020.setOpacity(ui.value / 100);
}
});
});
// L.hash(map, allMapLayers);
var layerHashKeys = {
'osm': osm,
'o': orto,
'm': harjumpbase,
'h': hybriid,
'k': kataster,
'p': pohi,
'sv': sauevyp,
'sl': sauelyp,
'ke': kernuyp,
'ni': nissiyp,
'hm': harjump,
'sakuyp': sakuyp2009,
'laagri2009': laagri2009,
'laagri2020': laagri2020,
'pk': puurkaev
};
L.myHash(map, layerHashKeys);