adds loop to route ancho popup
This commit is contained in:
@@ -154,6 +154,7 @@
|
|||||||
"login-details": "Login Details",
|
"login-details": "Login Details",
|
||||||
"logout": "Logout",
|
"logout": "Logout",
|
||||||
"longitude": "Längengrad",
|
"longitude": "Längengrad",
|
||||||
|
"loop": "",
|
||||||
"make-one": "Neues erstellen!",
|
"make-one": "Neues erstellen!",
|
||||||
"make-thumbnail": "Thumbnail festlegen",
|
"make-thumbnail": "Thumbnail festlegen",
|
||||||
"map": "Karte",
|
"map": "Karte",
|
||||||
|
|||||||
@@ -154,6 +154,7 @@
|
|||||||
"login-details": "Login details",
|
"login-details": "Login details",
|
||||||
"logout": "Logout",
|
"logout": "Logout",
|
||||||
"longitude": "Longitude",
|
"longitude": "Longitude",
|
||||||
|
"loop": "Loop",
|
||||||
"make-one": "Make one!",
|
"make-one": "Make one!",
|
||||||
"make-thumbnail": "Make thumbnail",
|
"make-thumbnail": "Make thumbnail",
|
||||||
"map": "Map",
|
"map": "Map",
|
||||||
|
|||||||
@@ -154,6 +154,7 @@
|
|||||||
"login-details": "Detalles de acceso",
|
"login-details": "Detalles de acceso",
|
||||||
"logout": "Salir",
|
"logout": "Salir",
|
||||||
"longitude": "Longitud",
|
"longitude": "Longitud",
|
||||||
|
"loop": "",
|
||||||
"make-one": "¡Crea uno!",
|
"make-one": "¡Crea uno!",
|
||||||
"make-thumbnail": "Generar miniaturas",
|
"make-thumbnail": "Generar miniaturas",
|
||||||
"map": "Mapa",
|
"map": "Mapa",
|
||||||
|
|||||||
@@ -154,6 +154,7 @@
|
|||||||
"login-details": "Données de connexion",
|
"login-details": "Données de connexion",
|
||||||
"logout": "Déconnexion",
|
"logout": "Déconnexion",
|
||||||
"longitude": "Longitude",
|
"longitude": "Longitude",
|
||||||
|
"loop": "",
|
||||||
"make-one": "Faites-en un !",
|
"make-one": "Faites-en un !",
|
||||||
"make-thumbnail": "Créer une miniature",
|
"make-thumbnail": "Créer une miniature",
|
||||||
"map": "Carte",
|
"map": "Carte",
|
||||||
|
|||||||
@@ -154,6 +154,7 @@
|
|||||||
"login-details": "Login details",
|
"login-details": "Login details",
|
||||||
"logout": "Kijelentkezés",
|
"logout": "Kijelentkezés",
|
||||||
"longitude": "Hosszúság",
|
"longitude": "Hosszúság",
|
||||||
|
"loop": "",
|
||||||
"make-one": "Készítsen egyet!",
|
"make-one": "Készítsen egyet!",
|
||||||
"make-thumbnail": "Készítsen miniatűrképet",
|
"make-thumbnail": "Készítsen miniatűrképet",
|
||||||
"map": "Térkép",
|
"map": "Térkép",
|
||||||
|
|||||||
@@ -154,6 +154,7 @@
|
|||||||
"login-details": "Dettagli del login",
|
"login-details": "Dettagli del login",
|
||||||
"logout": "Logout",
|
"logout": "Logout",
|
||||||
"longitude": "Longitudine",
|
"longitude": "Longitudine",
|
||||||
|
"loop": "",
|
||||||
"make-one": "Creane uno!",
|
"make-one": "Creane uno!",
|
||||||
"make-thumbnail": "Imposta miniatura",
|
"make-thumbnail": "Imposta miniatura",
|
||||||
"map": "Mappa",
|
"map": "Mappa",
|
||||||
|
|||||||
@@ -154,6 +154,7 @@
|
|||||||
"login-details": "Login details",
|
"login-details": "Login details",
|
||||||
"logout": "Uitloggen",
|
"logout": "Uitloggen",
|
||||||
"longitude": "Lengtegraad",
|
"longitude": "Lengtegraad",
|
||||||
|
"loop": "",
|
||||||
"make-one": "Maak er een aan!",
|
"make-one": "Maak er een aan!",
|
||||||
"make-thumbnail": "Miniatuur maken",
|
"make-thumbnail": "Miniatuur maken",
|
||||||
"map": "Kaart",
|
"map": "Kaart",
|
||||||
|
|||||||
@@ -154,6 +154,7 @@
|
|||||||
"login-details": "Dane logowania",
|
"login-details": "Dane logowania",
|
||||||
"logout": "Wyloguj",
|
"logout": "Wyloguj",
|
||||||
"longitude": "Wysokość",
|
"longitude": "Wysokość",
|
||||||
|
"loop": "",
|
||||||
"make-one": "Stwórz ją!",
|
"make-one": "Stwórz ją!",
|
||||||
"make-thumbnail": "Zrób miniaturkę",
|
"make-thumbnail": "Zrób miniaturkę",
|
||||||
"map": "Mapa",
|
"map": "Mapa",
|
||||||
|
|||||||
@@ -154,6 +154,7 @@
|
|||||||
"login-details": "Detalhes de login",
|
"login-details": "Detalhes de login",
|
||||||
"logout": "Sair",
|
"logout": "Sair",
|
||||||
"longitude": "Longitude",
|
"longitude": "Longitude",
|
||||||
|
"loop": "",
|
||||||
"make-one": "Faz um!",
|
"make-one": "Faz um!",
|
||||||
"make-thumbnail": "Faça miniatura",
|
"make-thumbnail": "Faça miniatura",
|
||||||
"map": "Mapa",
|
"map": "Mapa",
|
||||||
|
|||||||
@@ -154,6 +154,7 @@
|
|||||||
"login-details": "登录详情",
|
"login-details": "登录详情",
|
||||||
"logout": "登出",
|
"logout": "登出",
|
||||||
"longitude": "经度",
|
"longitude": "经度",
|
||||||
|
"loop": "",
|
||||||
"make-one": "立刻注册!",
|
"make-one": "立刻注册!",
|
||||||
"make-thumbnail": "生成缩略图",
|
"make-thumbnail": "生成缩略图",
|
||||||
"map": "地图",
|
"map": "地图",
|
||||||
|
|||||||
@@ -74,7 +74,8 @@ export function createMarkerFromWaypoint(waypoint: Waypoint, onDragEnd?: (marker
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function createAnchorMarker(lat: number, lon: number, index: number,
|
export function createAnchorMarker(lat: number, lon: number, index: number,
|
||||||
onDeleteClick: () => void, onDragStart: (event: Event) => void, onDragEnd: (event: Event) => void): FontawesomeMarker {
|
onDeleteClick: () => void, onLoopClick: () => void,
|
||||||
|
onDragStart: (event: Event) => void, onDragEnd: (event: Event) => void): FontawesomeMarker {
|
||||||
|
|
||||||
const anchorElement = document.createElement("span")
|
const anchorElement = document.createElement("span")
|
||||||
anchorElement.className = "route-anchor cursor-pointer rounded-full w-6 h-6 border border-black text-center bg-background-inverse text-content-inverse"
|
anchorElement.className = "route-anchor cursor-pointer rounded-full w-6 h-6 border border-black text-center bg-background-inverse text-content-inverse"
|
||||||
@@ -91,7 +92,7 @@ export function createAnchorMarker(lat: number, lon: number, index: number,
|
|||||||
const popupContent = document.createElement("div");
|
const popupContent = document.createElement("div");
|
||||||
const anchorH = document.createElement("h5")
|
const anchorH = document.createElement("h5")
|
||||||
anchorH.classList.add("text-base", "font-medium");
|
anchorH.classList.add("text-base", "font-medium");
|
||||||
anchorH.textContent = get(_)("route-point") + " #" + index;
|
anchorH.textContent = get(_)("route-point") + " #" + index;
|
||||||
|
|
||||||
const deleteButton = document.createElement("button");
|
const deleteButton = document.createElement("button");
|
||||||
deleteButton.className = "btn-secondary w-full mt-2 text-sm";
|
deleteButton.className = "btn-secondary w-full mt-2 text-sm";
|
||||||
@@ -104,8 +105,20 @@ export function createAnchorMarker(lat: number, lon: number, index: number,
|
|||||||
deleteButton.appendChild(deleteButtonText)
|
deleteButton.appendChild(deleteButtonText)
|
||||||
deleteButton.addEventListener("click", onDeleteClick)
|
deleteButton.addEventListener("click", onDeleteClick)
|
||||||
|
|
||||||
|
const loopButton = document.createElement("button");
|
||||||
|
loopButton.className = "btn-secondary w-full mt-2 text-sm block";
|
||||||
|
const loopButtonIcon = document.createElement("i")
|
||||||
|
loopButtonIcon.classList.add("fa", "fa-person-walking-arrow-loop-left", "mr-2")
|
||||||
|
loopButton.appendChild(loopButtonIcon)
|
||||||
|
const loopButtonText = document.createElement("span")
|
||||||
|
loopButtonText.textContent = get(_)("loop")
|
||||||
|
loopButton.appendChild(loopButtonIcon)
|
||||||
|
loopButton.appendChild(loopButtonText)
|
||||||
|
loopButton.addEventListener("click", onLoopClick)
|
||||||
|
|
||||||
popupContent.appendChild(anchorH)
|
popupContent.appendChild(anchorH)
|
||||||
popupContent.appendChild(deleteButton)
|
popupContent.appendChild(deleteButton)
|
||||||
|
popupContent.appendChild(loopButton)
|
||||||
popup.setDOMContent(popupContent)
|
popup.setDOMContent(popupContent)
|
||||||
marker.setPopup(popup);
|
marker.setPopup(popup);
|
||||||
|
|
||||||
|
|||||||
@@ -528,34 +528,34 @@
|
|||||||
if (anchorCount == 0) {
|
if (anchorCount == 0) {
|
||||||
addAnchor(e.lngLat.lat, e.lngLat.lng, anchors.length);
|
addAnchor(e.lngLat.lat, e.lngLat.lng, anchors.length);
|
||||||
} else {
|
} else {
|
||||||
const previousAnchor = anchors[anchorCount - 1];
|
await addAnchorAndRecalculate(e.lngLat.lat, e.lngLat.lng);
|
||||||
const anchor = addAnchor(
|
}
|
||||||
e.lngLat.lat,
|
}
|
||||||
e.lngLat.lng,
|
|
||||||
anchors.length,
|
async function addAnchorAndRecalculate(lat: number, lon: number) {
|
||||||
|
const previousAnchor = anchors[anchors.length - 1];
|
||||||
|
const anchor = addAnchor(lat, lon, anchors.length);
|
||||||
|
const markerText = startAnchorLoading(anchor);
|
||||||
|
try {
|
||||||
|
const routeWaypoints = await calculateRouteBetween(
|
||||||
|
previousAnchor.lat,
|
||||||
|
previousAnchor.lon,
|
||||||
|
lat,
|
||||||
|
lon,
|
||||||
|
selectedModeOfTransport,
|
||||||
|
autoRouting,
|
||||||
);
|
);
|
||||||
const markerText = startAnchorLoading(anchor);
|
insertIntoRoute(routeWaypoints);
|
||||||
try {
|
updateTrailWithRouteData();
|
||||||
const routeWaypoints = await calculateRouteBetween(
|
} catch (e) {
|
||||||
previousAnchor.lat,
|
console.error(e);
|
||||||
previousAnchor.lon,
|
show_toast({
|
||||||
e.lngLat.lat,
|
text: "Error calculating route",
|
||||||
e.lngLat.lng,
|
icon: "close",
|
||||||
selectedModeOfTransport,
|
type: "error",
|
||||||
autoRouting,
|
});
|
||||||
);
|
} finally {
|
||||||
insertIntoRoute(routeWaypoints);
|
stopAnchorLoading(anchor, markerText);
|
||||||
updateTrailWithRouteData();
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
show_toast({
|
|
||||||
text: "Error calculating route",
|
|
||||||
icon: "close",
|
|
||||||
type: "error",
|
|
||||||
});
|
|
||||||
} finally {
|
|
||||||
stopAnchorLoading(anchor, markerText);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -577,6 +577,14 @@
|
|||||||
() => {
|
() => {
|
||||||
removeAnchor(anchors.findIndex((a) => a.id == anchor.id));
|
removeAnchor(anchors.findIndex((a) => a.id == anchor.id));
|
||||||
},
|
},
|
||||||
|
() => {
|
||||||
|
const thisAnchor = anchors.find((a) => a.id == anchor.id);
|
||||||
|
addAnchorAndRecalculate(
|
||||||
|
thisAnchor?.lat ?? lat,
|
||||||
|
thisAnchor?.lon ?? lon,
|
||||||
|
);
|
||||||
|
marker.togglePopup();
|
||||||
|
},
|
||||||
(e) => {
|
(e) => {
|
||||||
draggingMarker = true;
|
draggingMarker = true;
|
||||||
},
|
},
|
||||||
@@ -815,7 +823,7 @@
|
|||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
<title
|
<title
|
||||||
>{$formData.id ? `${$formData.name} | ${$_("edit")}` : $_("new-trail")} |
|
>{$page.params.id !== "new" ? `${$formData.name} | ${$_("edit")}` : $_("new-trail")} |
|
||||||
wanderer</title
|
wanderer</title
|
||||||
>
|
>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|||||||
Reference in New Issue
Block a user