mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
huge Laravel 10 upgrade
This commit is contained in:
44
support/laravel-maps/resources/js/utils/leaflet.js
vendored
Normal file
44
support/laravel-maps/resources/js/utils/leaflet.js
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
import {openUrl} from './helper';
|
||||
import {dispatchEventMarkerClicked} from './dispatchEvent';
|
||||
|
||||
export function createMarker(service, element, map, markerData) {
|
||||
const {title, lat, lng, url, popup, icon, iconSize, iconAnchor} = markerData;
|
||||
|
||||
const markerOptions = {
|
||||
title,
|
||||
keyboard: false,
|
||||
draggable: false,
|
||||
};
|
||||
|
||||
if (icon) {
|
||||
const iconOptions = {
|
||||
iconUrl: icon,
|
||||
};
|
||||
if (iconSize) {
|
||||
iconOptions.iconSize = iconSize;
|
||||
}
|
||||
if (iconAnchor) {
|
||||
iconOptions.iconAnchor = iconAnchor;
|
||||
}
|
||||
markerOptions.icon = window.L.icon(iconOptions);
|
||||
}
|
||||
|
||||
const marker = window.L.marker([lat, lng], markerOptions);
|
||||
|
||||
marker.on('click', event => {
|
||||
event.originalEvent.preventDefault();
|
||||
dispatchEventMarkerClicked(service, element, map, marker);
|
||||
if (popup) {
|
||||
window.L.popup()
|
||||
.setLatLng([lat, lng])
|
||||
.setContent(popup)
|
||||
.openOn(map);
|
||||
} else if (url) {
|
||||
openUrl(url);
|
||||
}
|
||||
});
|
||||
|
||||
marker.addTo(map);
|
||||
|
||||
return marker;
|
||||
}
|
||||
Reference in New Issue
Block a user