From 2afe8b1b0a421a2b1f3473705de219f90306bc64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C5=82awomir=20Rodak?= Date: Fri, 27 Sep 2024 18:32:09 +0200 Subject: [PATCH] refactor: Update marker icon size and anchor position in MapManager.ts The marker icon size and anchor position in the MapManager class have been updated to improve the visual representation of the markers on the map. The icon size has been changed to [64, 64] pixels, and the anchor position has been adjusted to [32, 16] for the default marker and [32, 32] for markers with a specific direction. refactor: Update arrow icon size in marker.ts The arrow icon size in the marker.ts file has been updated to improve its visual appearance. The size of the arrow icon has been changed to 800px by 800px. refactor: Update pin icon size in marker.ts The pin icon size in the marker.ts file has been updated to improve its visual appearance. The size of the pin icon has been changed to 800px by 800px. --- src/scripts/MapManager.ts | 15 ++++----------- src/scripts/marker.ts | 7 +++++-- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/scripts/MapManager.ts b/src/scripts/MapManager.ts index 30b03b5..0af17cd 100644 --- a/src/scripts/MapManager.ts +++ b/src/scripts/MapManager.ts @@ -7,11 +7,6 @@ import ObserverPublisher from "./ObserverPublisher"; import Publisher from "./Publisher.class"; import { fault, log } from "./console.ts"; import { markerIcon } from "./marker.ts"; -/* - * TODO default center map in the center of Europe, save the latest position in local storage and use next time - * AND ZOOM LEVEL - * - */ const DEFAULT_CENTER: [number, number] = [54.403397, 18.570665]; const DEFAULT_ZOOM: number = 14; @@ -96,9 +91,8 @@ export default class MapManager extends ObserverPublisher(Publisher) { this.marker.setIcon( L.icon({ iconUrl: markerIcon(null), - iconSize: [80, 80], // size of the icon - iconAnchor: [40, 80], // point of the icon which will correspond to marker's location - popupAnchor: [40, 0], // point from which the popup should open relative to the iconAnchor + iconSize: [64, 64], // size of the icon + iconAnchor: [32, 16], // point of the icon which will correspond to marker's location }), ); this.show({ title: true }); @@ -117,9 +111,8 @@ export default class MapManager extends ObserverPublisher(Publisher) { this.marker.setIcon( L.icon({ iconUrl: markerIcon(dir), - iconSize: [80, 80], // size of the icon - iconAnchor: [40, 80], // point of the icon which will correspond to marker's location - popupAnchor: [40, 0], // point from which the popup should open relative to the iconAnchor + iconSize: [64, 64], // size of the icon + iconAnchor: [32, 32], // point of the icon which will correspond to marker's location }), ); } diff --git a/src/scripts/marker.ts b/src/scripts/marker.ts index 166de68..0255205 100644 --- a/src/scripts/marker.ts +++ b/src/scripts/marker.ts @@ -1,9 +1,12 @@ const arrowIcon = (direction: number): string => - ``; + ``; + const pinIcon: string = - ''; + ''; + const escapeSVG = (svg: string): string => svg.replace(/[<>#%{}"]/g, (x) => `%${x.charCodeAt(0).toString(16)}`); + export const markerIcon = (direction: number | null) => { const dataImagePrefix = "data:image/svg+xml,"; if (direction == null) {