-
Notifications
You must be signed in to change notification settings - Fork 1
/
pruebas.html
159 lines (154 loc) · 5.59 KB
/
pruebas.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
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Leaflet Panel Layers</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="/maps/leaflet/dist/leaflet.css" />
<link rel="stylesheet" href="../src/leaflet-panel-layers.css" />
<link rel="stylesheet" href="icons.css" />
<link rel="stylesheet" href="style.css" />
<style>
.leaflet-panel-layers {
background: rgba(255,255,255,0.8);
}
#map {
position: fixed;
top: 50px;
width:98%;
height: 90%;
}
</style>
</head>
<body>
<h3><a href="../"><big>◄</big> Leaflet Panel Layers</a></h3>
<h4> Multiple panels in compact mode</h4>
<br />
<div id="map"></div>
<div id="copy"><a href="http://labs.easyblog.it/">Labs</a> • <a rel="author" href="http://labs.easyblog.it/stefano-cudini/">Stefano Cudini</a></div>
<script src="/maps/leaflet/dist/leaflet-src.js"></script>
<script src="../src/leaflet-panel-layers.js"></script>
<script>
var conf = {
base: {
title: 'Others Base Layers',
layers: [
{
group: "Road Layers",
collapsed: true,
layers: [
{
name: "Esri Gray",
active: true,
layer: L.tileLayer('http://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}', {
attribution: 'Tiles © Esri — Esri, DeLorme, NAVTEQ',
maxZoom: 16
})
},
{
name: "Landscape",
layer: {
type: "tileLayer",
args: [
"http://{s}.tile3.opencyclemap.org/landscape/{z}/{x}/{y}.png"
]
}
}
]
},
{
group: "Land Cover",
layers: [
{
name: "Tree Cover 2000",
layer: {
type: "tileLayer",
args: [
"http://earthengine.google.org/static/hansen_2014/gfw_loss_tree_year_30_2014/{z}/{x}/{y}.png", {
attribution: "<a href='http://earthenginepartners.appspot.com/science-2013-global-forest'>Tree Cover (2000-2014, Hansen/UMD/Google/USGS/NASA)</a>",
maxZoom: 12
}
]
}
},
{
name: "Land Cover 2009",
layer: {
type: "tileLayer",
args: [
"https://s3.amazonaws.com/wri-tiles/global-landcover/{z}/{x}/{y}.png", {
attribution: "<a href='http://earthenginepartners.appspot.com/science-2013-global-forest'>Maps land cover distribution globally</a>",
maxZoom: 12
}
]
}
}
]
}
]
},
tree: {
title: "Tree Cover Trend",
layers: [
{
active: false,
name: "Gain",
layer: {
type: "tileLayer",
args: [
"http://earthengine.google.org/static/hansen_2013/gain_alpha/{z}/{x}/{y}.png", {
maxZoom: 12,
attribution:
'<a href="http://earthenginepartners.appspot.com/science-2013-global-forest"> '+
'Tree Cover Gain (12 years, 30m, global)</a>'
}
]
}
},
{
name: "Loss",
layer: {
type: "tileLayer",
args: [
"http://earthengine.google.org/static/hansen_2013/loss_alpha/{z}/{x}/{y}.png", {
maxZoom: 12,
attribution:
'<a href="http://earthenginepartners.appspot.com/science-2013-global-forest"> '+
'Tree Cover Loss (12 years, 30m, global)</a>'
}
]
}
}
]
}
};
var map = L.map('map', {
center: L.latLng([42.4918,12.4992]),
zoom: 3
});
var base1 = L.control.panelLayers(conf.base.layers, null, {
title: conf.base.title,
position: 'topright',
compact: true
}).addTo(map);
var over1 = L.control.panelLayers(null, conf.tree.layers, {
title: conf.tree.title,
position: 'topright',
compact: true
}).addTo(map);
var scale = L.control.scale().addTo(map);
map.on('zoomend', function() {
var y = map.getSize().y,
x = map.getSize().x;
// calculate the distance the one side of the map to the other using the haversine formula
var maxMeters = map.containerPointToLatLng([0, y]).distanceTo( map.containerPointToLatLng([x,y]));
// calculate how many meters each pixel represents
var MeterPerPixel = maxMeters/x ;
// say this is your scale
// This is the scale denominator
console.log('scale denominator: ',MeterPerPixel*scale.options.maxWidth);
console.log('zoom', map.getZoom() )
});
</script>
<script type="text/javascript" src="/labs-common.js"></script>
</body>
</html>