-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmenu.js
46 lines (41 loc) · 1.2 KB
/
menu.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
require(["dojo/query",
"dojo/dom-attr",
"dojo/domReady!"],
function(query, domAttr) {
// show/hide menu
var menuShown = false;
query('#menuBtn').connect('onclick', function() {
query('#menu').style('display', menuShown ? 'none' : 'block');
menuShown = !menuShown;
});
// menu buttons
query('button[data-layer]').connect('onclick', function() {
showLayer(domAttr.get(this, 'data-layer'));
query('#menu').style('display', 'none');
menuShown = false;
});
query('button[data-layer=radar').connect('onclick', function() {
if (map.getZoom() > 9) map.setZoom(9);
})
query('button[data-layer=imagery').connect('onclick', function() {
//alert(map.getZoom());
if (map.getZoom() > 18) map.setZoom(18);
})
});
function showLayer(layerId) {
var parts = layerId.split("-");
for (var i in map.layerIds) {
var id = map.layerIds[i];
if (id == parts[0]) {
map.getLayer(id).show();
if (parts.length > 1)
map.getLayer(id).setVisibleLayers([parts[1]]);
}
else if (id != "layer0") map.getLayer(id).hide();
}
for (var i in map.graphicsLayerIds) {
var id = map.graphicsLayerIds[i];
if (id == parts[0] || id.indexOf(parts[0]) == 0) map.getLayer(id).show();
else map.getLayer(id).hide();
}
}