constituencyMapExperimentClickable = {
const container = yield htl.html`<div style="height: 700px;">`;
const map = L.map(container);
const constituencylayer = L.geoJSON(constituencyFile).addTo(map);
function onEachFeature(feature, layer) {
if (feature.properties && feature.properties.CON_SEAT_) {
layer.bindTooltip(feature.properties.CON_SEAT_);
}
}
function myStyle(feature) {
return {
fillColor: "green",
weight: 2,
opacity: 0.05,
color: 'grey',
dashArray: '3',
fillOpacity: 0.15
};
}
function onLocationFound(e) {
var radius = e.accuracy;
L.marker(e.latlng).addTo(map)
.bindPopup("You are currently in this constituency").openPopup();
L.circle(e.latlng,
).addTo(map);
}
function highlightFeature(e) {
var layer = e.target;
layer.setStyle({
weight: 5,
color: '#666',
dashArray: '',
fillOpacity: 0.7
});
if (!L.Browser.ie && !L.Browser.opera && !L.Browser.edge) {
layer.bringToFront();
}
}
function resetHighlight(e) {
constituencyFile2.resetStyle(e.target);
}
map.on('locationfound', onLocationFound);
L.geoJSON(constituencyFile2, {
style: myStyle,
onEachFeature: onEachFeature,
filter: function(feature, layer){return feature.properties.CON_SEAT_}
}).addTo(map);
map.fitBounds(constituencylayer.getBounds(), {maxZoom: 19});
map.locate({setView: true, maxZoom: 9});
L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
attribution: "© <a href=https://www.openstreetmap.org/copyright>OpenStreetMap</a> contributors"
}).addTo(map);
}