'cant add mutiple markers on map - leaflet.js
OK so using leaflet.js I can't add multiple markers
const L = window.L;
L.LocUtil = {
locToCoords: (t, e) => {
var i = L.Projection.SphericalMercator,
n = t.loc1,
o = t.loc2;
e.switchedCoords && (o = [n, (n = o)][0]);
var r = {
x: (n - e.dx) / e.kx,
y: (o - e.dy) / e.ky,
};
return i.unproject(r);
},
};
var map = L.map("map").setView([0, 0], 1.5);
map.zoomControl.remove();
L.tileLayer(
"https://maps.izurvive.com/maps/CH-Sat/1.17.0/tiles/{z}/{x}/{y}.png",
{
tms: !0,
minZoom: 1,
noWrap: !0,
bounds: L.latLngBounds([-85, -180], [85, 180]),
}
).addTo(map);
var locations = [
["LOC 1", 4893.43, 9813.06],
["LOC 2", 4022.35, 9046.96],
];
for (var i = 0; i < locations.length; i++) {
marker = new L.circleMarker([locations[i][1], locations[i][2]], {
weight: 5,
color: "blue",
fillColor: "blue",
fillOpacity: 0.25,
radius: 2,
})
.bindPopup(locations[i][0])
.addTo(map);
}
Now the circleMarker works when I just specify 1 location without using the arrayhowever I tried adding multiple lat/long inside array and the map is loading just no makers being added
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
