polylines tooltip content
This commit is contained in:
75
utils/mapInitialization.js
Normal file
75
utils/mapInitialization.js
Normal file
@@ -0,0 +1,75 @@
|
||||
// /utils/mapInitialization.js
|
||||
import L from "leaflet";
|
||||
//import OverlappingMarkerSpiderfier from "overlapping-marker-spiderfier-leaflet";
|
||||
import "leaflet-contextmenu";
|
||||
import "leaflet/dist/leaflet.css";
|
||||
import "leaflet-contextmenu/dist/leaflet.contextmenu.css";
|
||||
import * as urls from "../config/urls.js";
|
||||
import * as layers from "../config/layers.js";
|
||||
import { addContextMenuToMarker, openInNewTab } from "../utils/contextMenuUtils.js";
|
||||
|
||||
export const initializeMap = (mapRef, setMap, setOms, setMenuItemAdded, addItemsToMapContextMenu, hasRights) => {
|
||||
const offlineTileLayer = urls.OFFLINE_TILE_LAYER;
|
||||
//const offlineTileLayer = process.env.OFFLINE_TILE_LAYER;
|
||||
const onlineTileLayer = urls.ONLINE_TILE_LAYER;
|
||||
//const onlineTileLayer = process.env.ONLINE_TILE_LAYER;
|
||||
const TALAS = layers.MAP_LAYERS.TALAS;
|
||||
const ECI = layers.MAP_LAYERS.ECI;
|
||||
const ULAF = layers.MAP_LAYERS.ULAF;
|
||||
const GSMModem = layers.MAP_LAYERS.GSMModem;
|
||||
const CiscoRouter = layers.MAP_LAYERS.CiscoRouter;
|
||||
const WAGO = layers.MAP_LAYERS.WAGO;
|
||||
const Siemens = layers.MAP_LAYERS.Siemens;
|
||||
const OTDR = layers.MAP_LAYERS.OTDR;
|
||||
const WDM = layers.MAP_LAYERS.WDM;
|
||||
const GMA = layers.MAP_LAYERS.GMA;
|
||||
const Sonstige = layers.MAP_LAYERS.Sonstige;
|
||||
const TALASICL = layers.MAP_LAYERS.TALASICL;
|
||||
|
||||
if (mapRef.current) {
|
||||
const initMap = L.map(mapRef.current, {
|
||||
center: [53.111111, 8.4625],
|
||||
zoom: 12,
|
||||
layers: [TALAS, ECI, ULAF, GSMModem, CiscoRouter, WAGO, Siemens, OTDR, WDM, GMA, Sonstige, TALASICL],
|
||||
minZoom: 5,
|
||||
maxZoom: 15,
|
||||
zoomControl: false,
|
||||
contextmenu: true,
|
||||
contextmenuItems: [
|
||||
{
|
||||
text: "Station öffnen (Tab)",
|
||||
icon: "/img/screen_new.png",
|
||||
callback: (e) => {
|
||||
const clickedMarker = e.relatedTarget;
|
||||
openInNewTab(e, clickedMarker);
|
||||
},
|
||||
},
|
||||
"-",
|
||||
],
|
||||
});
|
||||
|
||||
L.tileLayer(onlineTileLayer, {
|
||||
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
|
||||
}).addTo(initMap);
|
||||
|
||||
const overlappingMarkerSpiderfier = new OverlappingMarkerSpiderfier(initMap, {
|
||||
nearbyDistance: 20,
|
||||
});
|
||||
|
||||
setMap(initMap);
|
||||
setOms(overlappingMarkerSpiderfier);
|
||||
|
||||
initMap.on("zoomend", function () {
|
||||
if (initMap.getZoom() > 15) {
|
||||
initMap.setZoom(15);
|
||||
} else if (initMap.getZoom() < 5) {
|
||||
initMap.setZoom(5);
|
||||
}
|
||||
});
|
||||
|
||||
initMap.whenReady(() => {
|
||||
console.log("Karte ist jetzt bereit und initialisiert.");
|
||||
addItemsToMapContextMenu(hasRights);
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user