Skip to content

Commit

Permalink
Update index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielJDufour authored Sep 27, 2024
1 parent 86f5e8c commit 52891d0
Showing 1 changed file with 60 additions and 28 deletions.
88 changes: 60 additions & 28 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,20 +135,20 @@
.marker {
border: 2px solid #004360;
/* background: #00A3BD; */
border-radius: 40px;
height: 40px;
border-radius: 26px;
height: 26px;
text-align: center;
width: 40px;
width: 26px;
}
.marker-inner {
background: #00A3BD;
border-radius: 40px;
height: 30px;
border-radius: 20px;
height: 20px;
left: 50%;
position: absolute;
top: 50%;
transform: translate(-50%, -50%);
width: 30px;
width: 20px;
}
.marker-inner-power {
background: transparent;
Expand Down Expand Up @@ -270,31 +270,63 @@
}
});

fetch(window.app.config.closures)
.then(function (response) { return response.json(); })
.then(function (geojson) {
map.on('load', () => {
map.addSource('closures', {
"type": "geojson",
"data": geojson
});
map.addLayer({
'id': 'closures',
'type': 'line',
'source': 'closures',
'layout': {
'line-join': 'round',
'line-cap': 'round'
},
'paint': {
'line-color': 'rgb(230,81,0)',
'line-width': 8
}
fetch(window.app.config.closures)
.then(function (response) { return response.json(); })
.then(function (geojson) {
map.on('load', () => {
map.addSource('closures', {
"type": "geojson",
"data": geojson
});
map.addLayer({
'id': 'closures',
'type': 'line',
'source': 'closures',
'layout': {
'line-join': 'round',
'line-cap': 'round'
},
'paint': {
'line-color': 'rgb(230,81,0)',
'line-width': 8
}
});
});
});
});



map.on('load', () => {
// When a click event occurs on a feature in the places layer, open a popup at the
// location of the feature, with description HTML from its properties.
map.on('click', 'closures', (e) => {
const coordinates = e.features[0].geometry.coordinates.slice();
const Name = e.features[0].properties.Name;
const description = e.features[0].properties.description;

// Ensure that if the map is zoomed out such that multiple
// copies of the feature are visible, the popup appears
// over the copy being pointed to.
while (Math.abs(e.lngLat.lng - coordinates[0]) > 180) {
coordinates[0] += e.lngLat.lng > coordinates[0] ? 360 : -360;
}

new maplibregl.Popup()
.setLngLat(coordinates[0])
.setHTML(JSON.stringify(Name).replace(/"/g,"") + "</br>" + JSON.stringify(description).replace(/"/g,""))
.addTo(map);
});

// Change the cursor to a pointer when the mouse is over the places layer.
map.on('mouseenter', 'closures', () => {
map.getCanvas().style.cursor = 'pointer';
});

// Change it back to a pointer when it leaves.
map.on('mouseleave', 'closures', () => {
map.getCanvas().style.cursor = '';
});

});

// window.app.data.outage.forEach(function (point) {
// // create a DOM element for the marker
Expand Down

0 comments on commit 52891d0

Please sign in to comment.