valuePerAcreMap = {
let h = (width<600) ? width + 200: width * 0.75,
z = (width<600) ? 6.5 : 7,
container = DOM.element('div', { style: `width:${width}px;height:${h}px` });
yield container;
let valuePerAcreMap = L.map(container)
.setView([43.68, -70.26], 13)
let osmLayer = L.tileLayer('https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}@2x.png', {
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(valuePerAcreMap);
let parcelOverlay = L.geoJson(parcelCollection, {
pointToLayer: function (feature, latlng) {
let val21 = feature.properties.val21.taxableValue,
a = feature.properties.acreage,
c = (a > 0) ?
colorRamp2(val21/a) : '#fff';
return L.circleMarker(latlng, {
radius: 1.5,
color: "#000",
weight: 0,
opacity: 0.8,
fillOpacity: 1,
fillColor: c
});
},
onEachFeature: function(feature, layer) {
let val21 = feature.properties.val21.taxableValue,
a = feature.properties.acreage,
vpa = (a>0) ? (val21/a).toFixed(2) : 'N/A';
layer.bindTooltip(
'<h4>'+feature.properties.address+'</h4>' +
'<p>Total taxable value, 2021: $'+ internationalNumberFormat.format(val21) +
'<br/>Acreage: ' + a + ' acres' +
'<br/>Per acre: $' + internationalNumberFormat.format(vpa) + '</p>'
)}
}).addTo(valuePerAcreMap);
valuePerAcreMap.on('zoomend', function() {
var currentZoom = map.getZoom();
let z = (currentZoom > 14) ? 5 : 2;
let s = (currentZoom > 15) ? 1 : 0;
parcelOverlay.eachLayer(function (marker) { marker.setRadius(z); marker.setStyle({weight: s}); });
});
let legend = L.control({position: 'bottomleft'})
legend.onAdd = function (map) {var div = L.DomUtil.create('div', 'legend'); return l2};
legend.addTo(valuePerAcreMap);
}