Für ganz einfache Anwendungen kann man dies auch ohne Erweiterung lösen. Z.B. über ein angepasstes Template für das Inhaltselement HTML:
PHP-Code:
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.4/dist/leaflet.css"
integrity="sha512-puBpdR0798OZvTTbP4A8Ix/l+A4dHDD0DGqYW6RQ+9jxkRFclaxxQb/SJAWZfWAkuyeQUytO7+7N4QKrDh+drA=="
crossorigin=""/>
<script src="https://unpkg.com/leaflet@1.3.4/dist/leaflet.js"
integrity="sha512-nMMmRyTVoLYqjP9hrbed9S+FzjZHW5gY1TWCHA5ckwXZBadntCNs8kEqAWdrb9O7rxbCaA4lKTIWjDXZxflOcA=="
crossorigin=""></script>
<?php
$mapId = 'map_' . $this->id;
$data = explode("\n", $this->html, 3);
$popup = implode('\' + "\n" + \'', explode("\n", $data[2]));
?>
<div id="<?= $mapId ?>" class="ce-map" style="width:100%;height:40vh">
<script>
(function (mapId, markerCoordinates, markerTitle, markerPopup) {
var osm;
var marker;
var zoomLevel = 13;
var map = L.map(mapId).setView(markerCoordinates, zoomLevel);
osm = L.tileLayer( 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>',
subdomains: ['a','b','c']
});
osm.addTo(map);
marker = L.marker(markerCoordinates);
marker.addTo(map, {title: markerTitle, alt: markerTitle});
if (markerPopup) {
marker.bindPopup(markerPopup);
}
})('<?= $mapId ?>', [<?= $data[1] ?>], '<?= $data[0] ?>', '<?= $popup ?>', <?= $zoomLevel ?>);
</script>
Dann könnte man als Inhalt im Inhaltselement folgendes eingeben:
HTML-Code:
Hauptbahnhof Berlin
52.5250839,13.369402000000036
<p><h2>Berliner Hauptbahnhof</h2></p>
<p><a href="https://de.wikipedia.org/wiki/Berlin_Hauptbahnhof">Mehr erfahren</a></p>
Die erste Zeile wird als Titel und Alt-Attribut für den Marker genutzt. In der zweiten Zeile kommen die Koordinaten rein und alles was danach kommt wird als Popup gehandhabt. Natürlich lässt sich das auch noch ein eines der Elementgeneratoren gießen, wenn es noch komfortabler für die Redakteure sein soll.
Neben con4gis kannst du natürlich auch netzmacht/contao-leaflet-maps einsetzen, ist allerdings auch komplexer als die Google Maps Erweiterung. Version 3 ist mit Contao 4 kompatibel.
Lesezeichen