PhilMap2 = {
let container = DOM.element('div', { style: `width:${width}px;height:${width/1.6}px` });
yield container;
let map = L.map(container).setView([10.5, 120.9842], 7);
let osmLayer = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
function getColor(d) {
return d > 1000000 ? '#800026' :
d > 500000 ? '#BD0026' :
d > 100000 ? '#E31A1C' :
d > 50000 ? '#FC4E2A' :
d > 10000 ? '#FD8D3C' :
d > 5000 ? '#FEB24C' :
d > 1000 ? '#FED976' :
'#FFEDA0';
}
L.svg({clickable:true}).addTo(map)
const overlay = d3.select(map.getPanes().overlayPane)
const svg = overlay.select('svg').attr("pointer-events", "auto")
const g = svg.append('g').attr('class', 'leaflet-zoom-hide')
const projectPoint = function(x, y) {
const point = map.latLngToLayerPoint(new L.LatLng(y, x))
this.stream.point(point.x, point.y)
}
const projection = d3.geoTransform({point: projectPoint})
const pathCreator = d3.geoPath().projection(projection)
const areaPaths = g.selectAll('path')
.data(Phil.features)
.join('path')
.attr('fill', function(d, i) {
return getColor(Phil.features[i].properties.num)
})
.attr('stroke', 'black')
.attr("z-index", 3000)
.attr('stroke-width', 2.5)
map.on('click', () =>
mutable nHood = null
);
const onZoom = () => areaPaths.attr('d', pathCreator)
onZoom()
map.on('zoomend', onZoom)
}