mirror of
https://github.com/MeshTender/MeshTender.git
synced 2026-09-02 18:13:46 +00:00
25 lines
860 B
JavaScript
25 lines
860 B
JavaScript
// meshMap renders a dark-mode Leaflet map of points into the element with the
|
|
// given id. pts is an array of {name, lat, lon}. Does nothing if pts is empty.
|
|
function meshMap(elId, pts) {
|
|
if (!pts || !pts.length) return;
|
|
var map = L.map(elId, { scrollWheelZoom: false });
|
|
// CARTO "dark matter" basemap (OpenStreetMap data) for a dark UI.
|
|
L.tileLayer("https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png", {
|
|
maxZoom: 19,
|
|
subdomains: "abcd",
|
|
attribution: "© OpenStreetMap © CARTO",
|
|
}).addTo(map);
|
|
var group = L.featureGroup(
|
|
pts.map(function (p) {
|
|
return L.circleMarker([p.lat, p.lon], {
|
|
radius: 7,
|
|
color: "#4dabf7",
|
|
weight: 2,
|
|
fillColor: "#4dabf7",
|
|
fillOpacity: 0.6,
|
|
}).bindPopup(p.name);
|
|
})
|
|
).addTo(map);
|
|
map.fitBounds(group.getBounds().pad(0.3));
|
|
}
|