forked from CWFIS/exam-question
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathq2.html
68 lines (63 loc) · 3.21 KB
/
q2.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
<!DOCTYPE html>
<html>
<head>
<title>Alberta Active Fires</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=" crossorigin="" />
<script src="https://unpkg.com/[email protected]/dist/leaflet.js" integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script>
<style>
#mapid {
height: 600px;
}
</style>
</head>
<body>
<div id="mapid"></div>
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<script>
var map = L.map('mapid').setView([55, -113], 5);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors'
}).addTo(map);
fetch('https://cwfis.cfs.nrcan.gc.ca/geoserver/public/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=public:activefires_current&srsname=EPSG:4326&outputFormat=json&CQL_FILTER=properties%3aagency=%27ab%27')
.then(response => response.json())
.then(data => {
L.geoJSON(data.features, {
style: function (feature) {
var hectares = feature.properties.hectares;
var options = {
color: '#FF0000',
weight: 2,
fillOpacity: (hectares >= 1 && hectares <= 1000) ? 0.5 : (hectares < 1 || hectares === null) ? 0 : 1
}
return options;
},
onEachFeature: function (feature, layer) {
// Function to display fire details
function displayFireInfo() {
var popupContent = "<p>";
if (feature.properties.firename) {
popupContent += "<b>Name:</b> " + feature.properties.firename + "<br/>";
}
if (feature.properties.stage_of_control) {
popupContent += "<b>Stage of Control:</b> " + feature.properties.stage_of_control + "<br/>";
}
if (feature.properties.startdate) {
var date = new Date(feature.properties.startdate);
var formattedDate = date.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' });
popupContent += "<b>Start Date:</b> " + formattedDate + "<br/>";
}
popupContent += "</p>";
layer.bindPopup(popupContent).openPopup();
}
layer.on('click', displayFireInfo);
},
pointToLayer: function (feature, latlng) {
return L.circleMarker(latlng);
}
}).addTo(map);
});
</script>
</body>
</html>