-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
138 lines (125 loc) · 3.79 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title>Tipos Residenciales - AMB</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.53.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.53.0/mapbox-gl.css' rel='stylesheet' />
<style>
body { margin:0;
padding:0;
font-family: helvetica;
font-size: 14px;
}
#map { position:absolute; top:0; bottom:0; width:100%; }
li {
padding:3px 0;
}
#panel{
background: white;
width: 300px;
border: 1px solid rgba(0,0,0,0.05);
position: absolute;
right: 16px;
top: 16px;
box-shadow: 0 0 4px 0 rgba(0,0,0,0.1);
color: rgba(0,0,0,0.5);
}
h4 {
text-transform: uppercase;
border-bottom: 1px solid rgba(0,0,0,0.05);
margin: 0;
padding: 16px;
}
ul{
list-style-type: none;
margin: 0;
padding: 16px;
}
ul span {
width: 10px;
height: 10px;
display: inline-block;
margin-right: 8px;
border-radius: 50%;
}
dd{
margin-left: 0;
margin-bottom: 8px;
font-weight: bold;
}
.mapboxgl-popup-content{
font-size: 14px;
color: rgba(0,0,0,0.5);
min-width: 250px;
max-width: 400px;
box-shadow: 0 0 4px 0 rgba(0,0,0,0.1);
}
dl{
margin-bottom: 0;
}
</style>
</head>
<body>
<div id='map'></div>
<div id="panel" style="">
<h4>Tejido residencial - AMB</h4>
<ul>
<li><span style="background:#f9eddb;"></span>Unifamiliar</li>
<li><span style="background:#f6d9cb;"></span>Residencial Colectivo</li>
<li><span style="background:#f1b89c;"></span>Residencial Mixto</li>
<li><span style="background:#ffffff; border: 1px solid #ccc; box-sizing: border-box;"></span>Otros Usos // Sin Datos</li>
</ul>
</div>
<script>
mapboxgl.accessToken = 'pk.eyJ1Ijoicm9kcmlnb2JjbmVjb2xvZ2lhIiwiYSI6ImNqczRjbTF2YTAzY3Y0M2x4Nmh1cWM4NGoifQ.yFnumA_xNiN3_rVlCGnH_g';
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/rodrigobcnecologia/cjsdawrnf0gru1fpq9l2syv9y',
center: [2.177,41.382],
zoom: 14,
minZoom: 14,
maxZoom: 18,
hash: true
});
var nav = new mapboxgl.NavigationControl();
map.addControl(nav, 'top-left');
map.on('mousemove', function (event) {
var features = map.queryRenderedFeatures(event.point, {
layers: ['parcelario-amb']
});
map.getCanvas().style.cursor = (features.length) ? 'pointer':'';
});
map.on('click', function(event) {
var geometry = event.point;
var parameters = {
layers: ['parcelario-amb']
};
var features = map.queryRenderedFeatures(geometry, parameters);
var index = features[0];
console.log(index);
if (features.length) {
var REFCAT = index.properties.REFCAT || '—' ;
var LAND_USE = index.properties.LAND_USE || 'OTROS USOS / SIN DATOS';
var AREA = index.properties.AREA || '—';
var NUM_HABITA = index.properties.NUM_HABITA || '—';
console.log(REFCAT, LAND_USE, AREA);
var popup = new mapboxgl.Popup()
.setLngLat(event.lngLat)
.setHTML('<dl>' +
'<dt>REFCAT</dt>' +
'<dd>' + REFCAT + '</dd>' +
'<dt>LAND_USE</dt>' +
'<dd>' + LAND_USE + '</dd>' +
'<dt>AREA</dt>' +
'<dd>' + AREA + '</dd>' +
'<dt>NUM_HABITA</dt>' +
'<dd>' + NUM_HABITA + '</dd>' +
'</dl>')
.addTo(map);
}
});
</script>
</body>
</html>