-
Notifications
You must be signed in to change notification settings - Fork 0
/
land-use.html
178 lines (158 loc) · 5.3 KB
/
land-use.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
<!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.43.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.43.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: 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">
<h4>Land Use</h4>
<ul>
<li><span style="background: #F9EDDB;"></span>One & Two Family Buildings</li>
<li><span style="background: #F6D9CB;"></span>Multi-Family Buildings</li>
<li><span style="background: #F1B89C;"></span>Mixed Residential & Commercial Buildings</li>
<li><span style="background: #DF7649;"></span>Commercial & Office Buildings</li>
<li><span style="background: #CF4F4F;"></span>Industrial & Manufacturing</li>
<li><span style="background: #BEC6CC;"></span>Transportation & Utility</li>
<li><span style="background: #BDE7F4;"></span>Public Facilities & Institutions</li>
<li><span style="background: #A3D393;"></span>Open Space & Outdoor Recreation</li>
<li><span style="background: #8DA2B4;"></span>Parking Facilities</li>
<li><span style="background: #E4E4E4;"></span>Vacant Land</li>
<li><span style="background: #F9F9F9; border: 1px solid #ccc; box-sizing: border-box;"></span>No Data</li>
</ul>
</div>
<script>
var landUseNames = {
'01': 'One & Two Family Buildings',
'02': 'Multi-Family Walk-Up Buildings',
'03': 'Multi-Family Elevator Buildings',
'04': 'Mixed Residential & Commercial Buildings',
'05': 'Commercial & Office Buildings',
'06': 'Industrial & Manufacturing',
'07': 'Transportation & Utility',
'08': 'Public Facilities & Institutions',
'09': 'Open Space & Outdoor Recreation',
'10': 'Parking Facilities',
'11': 'Vacant Land'
};
mapboxgl.accessToken = 'pk.eyJ1IjoibmlubGluIiwiYSI6ImNqanR0Zzc4bzI5b2Ezd2xlb2ZmbzdrOHMifQ.nhMfjVcApf7oZVzhlMnRLA';
var map = new mapboxgl.Map({
container: 'map', // container id
style: 'mapbox://styles/mapbox/light-v1', // stylesheet location
center: [-73.995,40.73], // starting position [lng, lat]
zoom: 13,
minZoom: 13,
maxZoom: 18 // starting zoom
});
/*function onClick (event) {
console.log("Mouse clicked"),
console.log(event, event.point)
}
map.on("click", onClick);*/
var nav = new mapboxgl.NavigationControl();
map.addControl(nav, 'top-left');
map.on("mousemove", function(event) {
if(map.loaded()) {
var features = map.queryRenderedFeatures(event.point, {layers:["mn-mappluto-23n930"]});
map.getCanvas().style.cursor = features.length ? 'pointer':'';
/*if (features.length) {
//map.getCanvas().style.cursor="pointer";
//} else {
//map.getCanvas().style.cursor=""
}*/
//console.log(event)
}
});
map.on ("click", function(event) {
var geometry = event.point;
var parameters = {
layers:["mn-mappluto-23n930"]
};
var features = map.queryRenderedFeatures(geometry, parameters);
var lot = features[0];
console.log(lot);
if (features.length) {
var bbl = lot.properties.BBL || '—'; // if the value is present, show the value. if undefined, show the dash
var LandUse = landUseNames[lot.properties.LandUse] || '—';
var ZoneDist = lot.properties.ZoneDist1 || '—';
var BldgClass = lot.properties.BldgClass || '—';
var OwnerName = lot.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>