-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
334 lines (279 loc) · 8.61 KB
/
Copy pathindex.html
File metadata and controls
334 lines (279 loc) · 8.61 KB
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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>Camera Spotting Tour Map</title>
<!-- Leaflet CSS -->
<link
rel="stylesheet"
href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"
integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY="
crossorigin=""
/>
<style>
html, body {
height: 100%;
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
background: #fff;
}
#map {
width: 100%;
height: 100%;
}
/* Legend styling */
.legend {
position: absolute;
top: 12px;
left: 12px;
background: rgba(255,255,255,0.95);
border-radius: 10px;
padding: 10px 12px;
box-shadow: 0 4px 16px rgba(0,0,0,0.12);
font-size: 13px;
line-height: 1.4;
z-index: 1000;
}
.legend-row {
display: flex;
align-items: center;
margin-bottom: 6px;
}
.legend-row:last-child {
margin-bottom: 0;
}
.legend-swatch-point {
width: 12px;
height: 12px;
background: #1d4ed8;
border-radius: 50%;
border: 2px solid #ffffff;
box-shadow: 0 0 0 1px #1d4ed8;
margin-right: 6px;
}
.legend-swatch-radius {
width: 12px;
height: 12px;
background: rgba(29,78,216,0.15);
border-radius: 50%;
border: 1px solid #1d4ed8;
margin-right: 6px;
}
/* Popup styling */
.popup-wrapper {
max-width: 240px;
line-height: 1.4;
font-size: 14px;
}
.popup-title {
font-weight: 600;
font-size: 15px;
margin-bottom: 6px;
}
.popup-thumb {
width: 100%;
height: auto;
border-radius: 8px;
display: block;
margin-bottom: 8px;
object-fit: cover;
background: #ddd;
}
.popup-line {
background: #f5f5f5;
border-radius: 6px;
padding: 6px 8px;
margin-bottom: 4px;
word-break: break-word;
}
</style>
</head>
<body>
<div id="map"></div>
<!-- Legend -->
<div class="legend">
<!-- generic meaning of symbol -->
<div class="legend-row">
<div class="legend-swatch-point" style="background:#1d4ed8; box-shadow:0 0 0 1px #1d4ed8;"></div>
<div>Camera location</div>
</div>
<div class="legend-row">
<div class="legend-swatch-radius" style="background:rgba(29,78,216,0.15); border:1px solid #1d4ed8;"></div>
<div>10 m viewing distance</div>
</div>
<hr style="border:none;border-top:1px solid #ddd;margin:8px 0;" />
<!-- per-type colors -->
<div class="legend-row">
<div class="legend-swatch-point" style="background:#edc75c; box-shadow:0 0 0 1px #edc75c;"></div>
<div>Vandal Dome / Dome Camera</div>
</div>
<div class="legend-row">
<div class="legend-swatch-point" style="background:#fe0301; box-shadow:0 0 0 1px #fe0301;"></div>
<div>Bullet Camera</div>
</div>
<div class="legend-row">
<div class="legend-swatch-point" style="background:#00ff00; box-shadow:0 0 0 1px #00ff00;"></div>
<div>C-Mount Camera</div>
</div>
<div class="legend-row">
<div class="legend-swatch-point" style="background:#2a00ff; box-shadow:0 0 0 1px #2a00ff;"></div>
<div>PTZ Camera</div>
</div>
<div class="legend-row">
<div class="legend-swatch-point" style="background:#ff00ff; box-shadow:0 0 0 1px #ff00ff;"></div>
<div>Wireless Camera</div>
</div>
<div class="legend-row">
<div class="legend-swatch-point" style="background:#9511f3; box-shadow:0 0 0 1px #9511f3;"></div>
<div>360 Camera</div>
</div>
<div class="legend-row">
<div class="legend-swatch-point" style="background:#88ffff; box-shadow:0 0 0 1px #88ffff;"></div>
<div>Turret Camera</div>
</div>
<div class="legend-row">
<div class="legend-swatch-point" style="background:#0196a8; box-shadow:0 0 0 1px #0196a8;"></div>
<div>Doorbell Camera</div>
</div>
</div>
<!-- Leaflet JS -->
<script
src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"
integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo="
crossorigin="">
</script>
<script>
(function () {
// Path to your generated file (make sure it's in the same folder)
var GEOJSON_URL = 'cameras-new.geojson';
// 1. Initialize the map. We'll zoom to bounds after loading the data.
var map = L.map('map', {
zoomControl: true
});
// 2. Add a light / monochrome-ish basemap (Carto light_all)
L.tileLayer(
'https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png',
{
maxZoom: 20,
attribution: '© OpenStreetMap contributors © CARTO'
}
).addTo(map);
// We'll collect all lat/lngs from features so we can auto-fit
var allLatLngs = [];
// --- NEW: color map for each camera type ---
function colorForType(cameraTypeRaw) {
// normalize cameraType to make matching a bit safer
var t = (cameraTypeRaw || '').toLowerCase().trim();
// Your desired palette:
// Vanal Dome -> #edc75c
// Bullet -> #fe0301
// C-Mount -> #00ff00
// PTZ -> #2a00ff
// Wireless -> #ff00ff
// 360 -> #9511f3
// Turret dome -> #88ffff
// Doorbell Cam -> #0196a8
// We'll match these against the labels in the data:
// "Dome Camera"
if (t.includes('dome')) return '#edc75c';
// "Bullet Camera"
if (t.includes('bullet')) return '#fe0301';
// "C-Mount Camera"
if (t.includes('c-mount')) return '#00ff00';
// "PTZ (Pan Tilt Zoom) Camera"
if (t.includes('ptz')) return '#2a00ff';
// "Wireless Camera"
if (t.includes('wireless')) return '#ff00ff';
// "360 Camera"
if (t.includes('360')) return '#9511f3';
// "Turret Camera" (your palette calls this "Turret dome")
if (t.includes('turret')) return '#88ffff';
// "Doorbell Camera"
if (t.includes('doorbell')) return '#0196a8';
// fallback color for weird / unknown / "Unidentified Hanging Object"
return '#666666';
}
// Build the popup HTML for each feature
function buildPopupHTML(props) {
var cameraType = props.camera_type || 'Camera';
var imgURL = props.image_url || '';
var indoorOutdoor = props.indoor_outdoor || '';
var signage = props.signage_visible || '';
var html = '<div class="popup-wrapper">';
// Title
html += '<div class="popup-title">' + cameraType + '</div>';
// Thumbnail
if (imgURL) {
html += '<img class="popup-thumb" src="' + imgURL + '" alt="Camera image" />';
}
// Indoor / Outdoor
if (indoorOutdoor) {
html += '<div class="popup-line"><strong>Indoors / Outdoors:</strong> ' +
indoorOutdoor + '</div>';
}
// Signage visible?
if (signage) {
html += '<div class="popup-line"><strong>Signage visible?:</strong> ' +
signage + '</div>';
}
html += '</div>';
return html;
}
// 3. Fetch and add the GeoJSON to the map
fetch(GEOJSON_URL)
.then(function (resp) {
if (!resp.ok) {
throw new Error('Failed to load ' + GEOJSON_URL + ' (' + resp.status + ')');
}
return resp.json();
})
.then(function (geojsonData) {
// Build a Leaflet GeoJSON layer
var layer = L.geoJSON(geojsonData, {
pointToLayer: function (feature, latlng) {
var props = feature.properties || {};
var camType = props.camera_type || '';
var color = colorForType(camType);
// Create the main visible marker with per-type color
var marker = L.circleMarker(latlng, {
radius: 6,
color: '#ffffff', // white stroke outline
weight: 2,
fillColor: color, // per-type color
fillOpacity: 0.85
});
// Bind popup with camera info
marker.bindPopup(buildPopupHTML(props));
// Add a ~10 m viewing distance circle (halo).
// You could ALSO color this with 'color', if you want same-color halos.
var circle = L.circle(latlng, {
radius: 10, // meters
color: color,
weight: 1,
fillColor: color,
fillOpacity: 0.15
});
circle.addTo(map);
// Track this point so we can fit the map later
allLatLngs.push(latlng);
return marker;
}
}).addTo(map);
// Fit the map to include all points
if (allLatLngs.length > 0) {
var bounds = L.latLngBounds(allLatLngs);
map.fitBounds(bounds.pad(0.2));
} else {
// fallback view (center somewhere sensible)
map.setView([52.3725, 4.9175], 16);
}
})
.catch(function (err) {
console.error(err);
alert('Could not load cameras-new.geojson. See console for details.');
});
})();
</script>
</body>
</html>