33 lines
No EOL
1.5 KiB
JavaScript
33 lines
No EOL
1.5 KiB
JavaScript
export function initMarkers(markerList, L, map){
|
|
markerList.forEach(customMarker => {
|
|
var marker = L.marker([customMarker.x, customMarker.y]).addTo(map);
|
|
let popUpContentTitle = "<h1>"+ customMarker.title +"</h1>";
|
|
let popUpContentdescription = "<p>"+ customMarker.description +"</p>";
|
|
let popUpContentImage = "<img src='/img/"+ customMarker.imgName+"'</img>";
|
|
let popUpContent = popUpContentTitle + popUpContentdescription + popUpContentImage
|
|
marker.bindPopup(popUpContent).openPopup();
|
|
});
|
|
}
|
|
|
|
export function createMarker(markerData, L, map, returnMarker = false){
|
|
var marker = L.marker([markerData.coordinate.y, markerData.coordinate.x]).addTo(map);
|
|
let popUpContentTitle = "<h1>"+ markerData.name +"</h1>";
|
|
let popUpContentdescription = "<p>"+ markerData.description +"</p>";
|
|
let popUpContentImage = "<img src='/imgs/"+ markerData.filename +"'</img>";
|
|
let popUpContent = popUpContentTitle + popUpContentdescription + popUpContentImage
|
|
marker.bindPopup(popUpContent);
|
|
if(returnMarker) {
|
|
return marker;
|
|
};
|
|
}
|
|
|
|
export function updateMarkers(markerList, L, map){
|
|
var layers = L.LayerGroup(), //layers contains all markers..
|
|
contained = []; //makers in map boundingbox
|
|
|
|
layers.eachLayer(function(l) {
|
|
if( l instanceof L.Marker && map.getBounds().contains(l.getLatLng()) )
|
|
contained.push(l);
|
|
});
|
|
console.log(contained)
|
|
} |