mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
fix markers update issue on load
This commit is contained in:
parent
19a8db4a17
commit
380575be5f
1 changed files with 45 additions and 41 deletions
|
|
@ -875,6 +875,8 @@ function parseLoadedData(data) {
|
||||||
// v 1.7 changed markers data
|
// v 1.7 changed markers data
|
||||||
const defs = document.getElementById("defs-markers");
|
const defs = document.getElementById("defs-markers");
|
||||||
const markersGroup = document.getElementById("markers");
|
const markersGroup = document.getElementById("markers");
|
||||||
|
|
||||||
|
if (defs && markersGroup) {
|
||||||
const markerElements = markersGroup.querySelectorAll("use");
|
const markerElements = markersGroup.querySelectorAll("use");
|
||||||
const rescale = +markersGroup.getAttribute("rescale");
|
const rescale = +markersGroup.getAttribute("rescale");
|
||||||
|
|
||||||
|
|
@ -885,6 +887,7 @@ function parseLoadedData(data) {
|
||||||
|
|
||||||
let x = +el.dataset.x;
|
let x = +el.dataset.x;
|
||||||
let y = +el.dataset.y;
|
let y = +el.dataset.y;
|
||||||
|
|
||||||
const transform = el.getAttribute("transform");
|
const transform = el.getAttribute("transform");
|
||||||
if (transform) {
|
if (transform) {
|
||||||
const [dx, dy] = parseTransform(transform);
|
const [dx, dy] = parseTransform(transform);
|
||||||
|
|
@ -896,16 +899,16 @@ function parseLoadedData(data) {
|
||||||
|
|
||||||
const href = el.href.baseVal;
|
const href = el.href.baseVal;
|
||||||
const type = href.replace("#marker_", "");
|
const type = href.replace("#marker_", "");
|
||||||
const symbol = defs.querySelector(`symbol${href}`);
|
const symbol = defs?.querySelector(`symbol${href}`);
|
||||||
const text = symbol.querySelector("text");
|
const text = symbol?.querySelector("text");
|
||||||
const circle = symbol.querySelector("circle");
|
const circle = symbol?.querySelector("circle");
|
||||||
|
|
||||||
const icon = text.innerHTML;
|
const icon = text?.innerHTML;
|
||||||
const px = Number(text.getAttribute("font-size")?.replace("px", ""));
|
const px = text && Number(text.getAttribute("font-size")?.replace("px", ""));
|
||||||
const dx = Number(text.getAttribute("x")?.replace("%", ""));
|
const dx = text && Number(text.getAttribute("x")?.replace("%", ""));
|
||||||
const dy = Number(text.getAttribute("y")?.replace("%", ""));
|
const dy = text && Number(text.getAttribute("y")?.replace("%", ""));
|
||||||
const fill = circle.getAttribute("fill");
|
const fill = circle && circle.getAttribute("fill");
|
||||||
const stroke = circle.getAttribute("stroke");
|
const stroke = circle && circle.getAttribute("stroke");
|
||||||
|
|
||||||
const marker = {i, icon, type, x, y, size, cell};
|
const marker = {i, icon, type, x, y, size, cell};
|
||||||
if (size && size !== 30) marker.size = size;
|
if (size && size !== 30) marker.size = size;
|
||||||
|
|
@ -914,7 +917,7 @@ function parseLoadedData(data) {
|
||||||
if (!isNaN(dy) && dy !== 50) marker.dy = dy;
|
if (!isNaN(dy) && dy !== 50) marker.dy = dy;
|
||||||
if (fill && fill !== "#ffffff") marker.fill = fill;
|
if (fill && fill !== "#ffffff") marker.fill = fill;
|
||||||
if (stroke && stroke !== "#000000") marker.stroke = stroke;
|
if (stroke && stroke !== "#000000") marker.stroke = stroke;
|
||||||
if (circle.getAttribute("opacity") === "0") marker.pin = "no";
|
if (circle?.getAttribute("opacity") === "0") marker.pin = "no";
|
||||||
|
|
||||||
return marker;
|
return marker;
|
||||||
});
|
});
|
||||||
|
|
@ -924,6 +927,7 @@ function parseLoadedData(data) {
|
||||||
markerElements.forEach(el => el.remove());
|
markerElements.forEach(el => el.remove());
|
||||||
if (layerIsOn("markers")) drawMarkers();
|
if (layerIsOn("markers")) drawMarkers();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
void (function checkDataIntegrity() {
|
void (function checkDataIntegrity() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue