function* stJoeMap() {
let container = DOM.element('div', { style: `width:940px;height:600px` });
yield container;
const baseMap = L.tileLayer(m.POS[0],m.POS[1])
let map = L.map(container).setView([42, -85.5], 9);
baseMap.addTo(map);
const popup = L.popup();
const onMapClick = (e) => {popup.setLatLng(e.latlng)
.setContent(`You clicked the map at: <h3>${e.latlng.toString()} </h3>`).openOn(map)};
map.on('click', onMapClick);
const simplePolygon = {"color":"#00ebc4", "weight":.75, "opacity":.7, "fillOpacity":0};
const gageStyle = (feature) => {
const d = feature.properties.status;
const gColor = d == 'LOW' ? 'red' : d == 'MUCH BELOW NORMAL' ? 'orangered' : d == 'BELOW NORMAL' ? 'orange' : d == 'NORMAL' ? 'green' : d == 'ABOVE NORMAL' ? 'darkblue' : d == 'MUCH ABOVE NORMAL' ? 'black': 'grey';
return { radius: 15, fillColor: gColor, color: "grey", weight: 3, fillOpacity: 0.8};
};
const highlightFeature = (e) => {
const layer = e.target;
layer.setStyle({ weight: 4, color: '#32cfb1', dashArray: '', fillOpacity: 0.6 });
layer.bringToFront();
info.update(layer.feature.properties);
}
const resetHighlight = (e) => {
layer1.resetStyle(e.target);
info.update();
}
const zoomToFeature = (e) => map.fitBounds(e.target.getBounds());
function bPop (feature,layer) {
const p = feature.properties;
console.log(p);
layer.bindPopup(`<h3>${p.info}</h3>
<ul><li>Gage Status: <b>${p.status} </b></li>
<li>Discharge: <b>${p.stationInfo.siteFlow} ft3/sec</b></li>
<li>Gage Height: <b>${p.stationInfo.gageHeight} ft</b></li>
<li>Station ID: <b>${p.ID}</b></li>`)
.on({ mouseover: highlightFeature,mouseout: resetHighlight,click: zoomToFeature })};
// Generates the info div box in the upper right hand corner
let info = L.control();
info.onAdd = function (map) {
this._div = L.DomUtil.create('div', 'info'); // create a div with a class "info"
this.update();
return this._div;
};
// method that we will use to update the control based on feature properties passed
info.update = function (props) {
this._div.innerHTML = '<h4>STATION STATUS:</h4>' + (props ?
'<b>'+props.status +'</b><br />'+ props.info + '<br />' + props.stationInfo.siteFlow + ' ft3/s' + ' - ' + props.stationInfo.gageHeight + ' ft ' + ' - ' + ' ID: ' + props.ID: 'Hover over a station')};
info.addTo(map);
// Add SF Buildings GeoJSON layer and add to map
//let layer1 = L.geoJSON(geoData1, { style: layer2Style, onEachFeature: bPop }).addTo(map);
const layer1 = L.geoJSON(geoData1, {style: gageStyle, onEachFeature: bPop,pointToLayer: function (feature, latlng) {
return L.circleMarker(latlng);
}
}).addTo(map);
}