/* eslint-disable @typescript-eslint/restrict-template-expressions */ /* eslint-disable @typescript-eslint/no-unsafe-return */ /* eslint-disable @typescript-eslint/prefer-nullish-coalescing */ import { divIcon, Point } from 'leaflet' import type { MarkerIcon } from '#types/MarkerIcon' const createSvg = (shape: string, markerColor: string, borderColor: string) => { const svgMap = { circle: '', square: '', star: '', penta: '', } // eslint-disable-next-line security/detect-object-injection return svgMap[shape] } const MarkerIconFactory = ( shape: string, color1: string, color2: string, icon?: MarkerIcon, assetsURL?: string, ) => { if (icon) return divIcon({ html: `
${createSvg(shape, color1, color2)}
`, iconAnchor: [17, 40], popupAnchor: [0, -40], iconSize: new Point(40, 46), className: 'leaflet-data-marker', shadowAnchor: [0, 0], }) else return divIcon({ html: `
${createSvg(shape, color1, color2)}
`, iconAnchor: [17, 40], popupAnchor: [0, -40], iconSize: new Point(40, 46), className: 'leaflet-data-marker', shadowAnchor: [0, 0], }) } export default MarkerIconFactory