-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
251 lines (192 loc) · 7.67 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
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
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title>Land Use</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.1/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.48.0/mapbox-gl.css' rel='stylesheet'/>
<style>
body
{
margin:0;
padding:0;
font-family:sans-serif;
font-size:14px;
}
#map {position:absolute; top:0; bottom:0; width:100%;}
li
{padding: 3px 0;}
#panel
{
background: white;
width: 400px;
border-style:solid;
border-width:1px;
border-color:rgba(0,0,0,0.05);
position:absolute;
right:16px;
top:16px;
box-shadow: 0 0 4px 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.5)''
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-family:sans-serif;
font-size:14px;
background: white;
width: 200px;
border-style:solid;
border-width:1px;
border-color:rgba(0,0,0,0.05);
right:16px;
top:16px;
box-shadow: 0 0 4px rgba(0,0,0,0.1);
color: rgba(0,0,0, 0.5);
min-width: 150px;
max-width: 400px;
}
dl
{
margin-bottom: 0;
}
</style>
</head>
<body>
<div id='map'></div>
<div id="panel">
<h4>Land Use</h4>
<ul>
<li><span style="background: #F9EDDB;"></span>One and Two Family Buildings</li>
<li><span style="background: #f6d9cb;"></span>Multi-Family Walk-up Buildings</li>
<li><span style="background: #f6d9cb;"></span>Multi-Family Elevator Buildings</li>
<li><span style="background: #f1b89c;"></span>Mixed Residential and Commercial Buildings</li>
<li><span style="background: #ff8591;"></span>Commercial and Office Buildings</li>
<li><span style="background: #6a3d9a;"></span>Industrial and Manufaacturing</li>
<li><span style="background: #6a7280;"></span>Transportation and Utility</li>
<li><span style="background: #7bbae4;"></span>Public Facilities and Institutions</li>
<li><span style="background: #a5df6f;"></span>Open Space and Outdorr Recreation</li>
<li><span style="background: #8da2b4;"></span>Parking Facility</li>
<li><span style="background: #9faabf;"></span>Vacant Land
<li><span style="background: #f9f9f9; border: 1px solid #ccc; box-sizing:border-box;"></span>No Data
</li>
</ul>
</div>
<script>
var LandUseNames = {
'01':'One and Two Family Buildings',
'02':'Multi-Family Walk-up Buildings',
'03':'Multi-Family Elevator Buildings',
'04':'Mixed Residential and Commercial Buildings',
'05':'Commercial and Office Buildings',
'06':'Industrial and Manufaacturing',
'07':'Transportation and Utility',
'08':'Public Facilities and Institutions',
'09':'Open Space and Outdorr Recreation',
'10':'Parking Facility',
'11':'Vacant Land',
'12':'No Data',
};
mapboxgl.accessToken = 'pk.eyJ1IjoiYmxhY2tzbm93bGVvcGFyZCIsImEiOiJjanI3cDMwdzUwaDBjNGFwZmZ5OWZtdW0yIn0.rM-0W9b4dFC58XHanjTsig';
var map = new mapboxgl.Map({
container: 'map', // container id
style: 'mapbox://styles/blacksnowleopard/cjta5du6x0w221fsbqgsrvx45', // stylesheet location
center: [-73.980,40.756], // starting position [lng, lat]
zoom: 13,
minZoom: 13,
maxZoom: 18, // starting zoom
hash: true
});
/*
function onClick(event)
{
console.log('Mouse Click');
console.log(event.point);
}
map.on('click', onClick)
*/
var nav = new mapboxgl.NavigationControl();
map.addControl (nav,'top-left');
// Add zoom and rotation controls to the map.
//map.addControl(new mapboxgl.NavigationControl());
map.on('mousemove', function(event){
//console.log(event);
if(map.loaded()){
var features = map.queryRenderedFeatures(event.point,{
layers: ['Lots']
});
map.getCanvas().style.cursor = features.length ? 'pointer':'';
}
/* if (features.length) {
map.getCanvas().style.cursor='pointer';
} else {
map.getCanvas().style.cursor='';
}*/
});
map.on('click',function(event) {
console.log('Mouse Click');
console.log(event.point);
var geometry = event.point;
var parameters = {
layers: ['Lots']
};
var features = map.queryRenderedFeatures(geometry,parameters);
//console.log(features);
//console.log(features.length + 'features');
var Lots = features[0];
console.log(Lots);
if (features.length)
{
var bbl = Lots.properties.BBL||'—';
var LandUse = LandUseNames[Lots.properties.LandUse]||'—';
var ZoneDist = Lots.properties.ZoneDist1||'—';
var BldgClass = Lots.properties.BldgClass||'—';
var OwnerName = Lots.properties.OwnerName||'—';
console.log(bbl, LandUse, ZoneDist, BldgClass, OwnerName);
var popup = new mapboxgl.Popup()
.setLngLat(event.lngLat)
.setHTML( '<dl>'+
'<dt>BBL<//dt>'+
'<dd>'+bbl+'</dd>'+
'<dt>Land Use<//dt>'+
'<dd>'+LandUse+'</dd>'+
'<dt>Zoning District<//dt>'+
'<dd>'+ZoneDist+'</dd>'+
'<dt>Building Class<//dt>'+
'<dd>'+BldgClass+'</dd>'+
'<dt>Owner<//dt>'+
'<dd>'+OwnerName+'</dd>'+
'</dl>')
.addTo(map);
}
});
</script>
</body>
</html>