From 4eb552a0aeae685b5dd7dcf41dfd2966fc5f10c0 Mon Sep 17 00:00:00 2001 From: Marwin Hochfelsner <50826859+hlfan@users.noreply.github.com> Date: Fri, 2 May 2025 03:35:45 +0200 Subject: [PATCH] Use common note marker definitions --- app/assets/javascripts/index/layers/notes.js | 4 ++-- app/assets/javascripts/index/new_note.js | 4 ++-- app/assets/javascripts/index/note.js | 2 +- app/assets/javascripts/leaflet.map.js | 8 +++++++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/index/layers/notes.js b/app/assets/javascripts/index/layers/notes.js index 00f1fb4e9..6c9f0f97d 100644 --- a/app/assets/javascripts/index/layers/notes.js +++ b/app/assets/javascripts/index/layers/notes.js @@ -23,7 +23,7 @@ OSM.initializeNotesLayer = function (map) { function updateMarker(old_marker, feature) { let marker = old_marker; if (marker) { - marker.setIcon(OSM.getMarker({ icon: `${feature.properties.status}_NOTE_MARKER`, shadow: false, height: 40 })); + marker.setIcon(OSM.noteMarkers[feature.properties.status]); } else { let title; const description = feature.properties.comments[0]; @@ -33,7 +33,7 @@ OSM.initializeNotesLayer = function (map) { } marker = L.marker(feature.geometry.coordinates.reverse(), { - icon: OSM.getMarker({ icon: `${feature.properties.status}_NOTE_MARKER`, shadow: false, height: 40 }), + icon: OSM.noteMarkers[feature.properties.status], title, opacity: 0.8, interactive: true diff --git a/app/assets/javascripts/index/new_note.js b/app/assets/javascripts/index/new_note.js index d852d7482..220559c58 100644 --- a/app/assets/javascripts/index/new_note.js +++ b/app/assets/javascripts/index/new_note.js @@ -32,7 +32,7 @@ OSM.NewNote = function (map) { function addCreatedNoteMarker(feature) { const marker = L.marker(feature.geometry.coordinates.reverse(), { - icon: OSM.getMarker({ icon: `${feature.properties.status}_NOTE_MARKER`, shadow: false, height: 40 }), + icon: OSM.noteMarkers[feature.properties.status], opacity: 0.9, interactive: true }); @@ -62,7 +62,7 @@ OSM.NewNote = function (map) { if (newNoteMarker) map.removeLayer(newNoteMarker); newNoteMarker = L.marker(latlng, { - icon: OSM.getMarker({ icon: "NEW_NOTE_MARKER", shadow: false, height: 40 }), + icon: OSM.noteMarkers.new, opacity: 0.9, draggable: true }); diff --git a/app/assets/javascripts/index/note.js b/app/assets/javascripts/index/note.js index a77735c95..a587daf49 100644 --- a/app/assets/javascripts/index/note.js +++ b/app/assets/javascripts/index/note.js @@ -69,7 +69,7 @@ OSM.Note = function (map) { type: "note", id: parseInt(id, 10), latLng: L.latLng(data.coordinates.split(",")), - icon: OSM.getMarker({ icon: `${data.status}_NOTE_MARKER`, shadow: false, height: 40 }) + icon: OSM.noteMarkers[data.status] }, function () { if (!hashParams.center && !skipMoveToNote) { const latLng = L.latLng(data.coordinates.split(",")); diff --git a/app/assets/javascripts/leaflet.map.js b/app/assets/javascripts/leaflet.map.js index 20b620046..78f967cb2 100644 --- a/app/assets/javascripts/leaflet.map.js +++ b/app/assets/javascripts/leaflet.map.js @@ -379,7 +379,7 @@ OSM.isDarkMap = function () { OSM.getMarker = function ({ icon = "MARKER_RED", shadow = true, height = 41 }) { const options = { - iconUrl: OSM[icon.toUpperCase()] || OSM.MARKER_RED, + iconUrl: OSM[icon] || OSM.MARKER_RED, iconSize: [25, height], iconAnchor: [12, height], popupAnchor: [1, -34] @@ -391,3 +391,9 @@ OSM.getMarker = function ({ icon = "MARKER_RED", shadow = true, height = 41 }) { } return L.icon(options); }; + +OSM.noteMarkers = { + "closed": OSM.getMarker({ icon: "CLOSED_NOTE_MARKER", shadow: false, height: 40 }), + "new": OSM.getMarker({ icon: "NEW_NOTE_MARKER", shadow: false, height: 40 }), + "open": OSM.getMarker({ icon: "OPEN_NOTE_MARKER", shadow: false, height: 40 }) +}; -- 2.39.5