import {rn} from "/src/utils/numberUtils"; const pinShapeMap = { bubble: (stroke, fill) => ``, pin: (stroke, fill) => ``, square: (stroke, fill) => ``, squarish: (stroke, fill) => ``, diamond: (stroke, fill) => ``, hex: (stroke, fill) => ``, hexy: (stroke, fill) => ``, shieldy: (stroke, fill) => ``, shield: (stroke, fill) => ``, pentagon: (stroke, fill) => ``, heptagon: (stroke, fill) => ``, circle: (stroke, fill) => ``, no: (stroke, fill) => "" }; export function drawMarkers() { const rescale = +markers.attr("rescale"); const pinned = +markers.attr("pinned"); const markersData = pinned ? pack.markers.filter(({pinned}) => pinned) : pack.markers; const html = markersData.map(marker => drawMarker(marker, rescale)); markers.html(html.join("")); } export function drawMarker(marker, rescale = 1) { const {i, icon, x, y, dx = 50, dy = 50, px = 12, size = 30, pin = "bubble", fill = "#fff", stroke = "#000"} = marker; const id = `marker${i}`; const zoomSize = rescale ? Math.max(rn(size / 5 + 24 / scale, 2), 1) : size; const viewX = rn(x - zoomSize / 2, 1); const viewY = rn(y - zoomSize, 1); const pinHTML = pinShapeMap[pin](fill, stroke); return /* html */ ` ${pinHTML} ${icon} `; }