mapHTML = {
const container = yield htl.html`<div id="nyc_prek_map_div" style="height: 600px;">`;
const map = L.map(container).setView([40.7678, -73.9645], 11);
let basemapLayers = Array(4).fill(null),
basemapNames = ['Stadia.StamenWatercolor', "Esri.WorldStreetMap", "OpenStreetMap.Mapnik", "Esri.WorldGrayCanvas"];
basemapNames.forEach((v, i) => {
basemapLayers[i] = L.tileLayer.provider(v);
});
basemapLayers[3].addTo(map);
L.marker(L.latLng(40.7678, -73.9645),
{
title: "Hunter College",
opacity: 0.8,
riseOnHover: true}).bindPopup("This is a point added to Leaflet for Hunter College").
addTo(map);
L.marker(L.latLng(40.7678, -73.97),
{ icon: mtaIcon,
title: "Hunter College Station",
opacity: 0.8,
riseOnHover: true}).bindPopup("This is a point added to Leaflet for Hunter College").
addTo(map);
let nycSchoolsLayer = L.geoJSON(null, {
style: (f) => {
if(f.properties.school_dis > 25)
return {color:"red",
weight: 1};
else
return {color:"blue",
weight: 2};
},
onEachFeature: (f, l) => {
l.bindPopup("The school district number is " + f.properties.school_dis);
}
});
nycSchoolsLayer.addData(schoolDistricts);
let nycPreKLayer = L.geoJSON(null, {
pointToLayer: (f, latLon) => {
let cL = L.circle(latLon, {radius: 56, color: "blue", weight: 1});
cL.bindPopup("URL is " + f.properties.Website);
return cL;
},
style: {color: "blue"}
}).addTo(map);
fetch("https://raw.githubusercontent.com/SunCodeEarth/SunCodeEarth.github.io/master/demo/nyc_prek/nyc_prek.geojson").then((response) => {
return response.json();
}).then((data) => {
nycPreKLayer.addData(data);
});
var baseMaps = {};
basemapLayers.forEach((v,i)=>{
baseMaps[basemapNames[i]] = v;
});
var overlayMaps = {
"<em>Pre-K </em> Schools": nycPreKLayer,
"<span style=\"background-color:DodgerBlue; color: white\">School Boundary</span>": nycSchoolsLayer,
};
var layerControl = L.control.layers(baseMaps, overlayMaps).addTo(map);
mutable mapVariables = [map, nycPreKLayer];
}