Skip to content

Commit

Permalink
remove gpx layer
Browse files Browse the repository at this point in the history
  • Loading branch information
strukturart committed Jul 22, 2023
1 parent a5b2b79 commit 13afa4c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 11 deletions.
16 changes: 15 additions & 1 deletion application/assets/js/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,19 @@ const module = (() => {
return markers_collection[index];
};

let remove_gpx = function () {
let i = 0;
gpx_group.eachLayer(function (l) {
i++;
if (i == gpx_selection_count + 1) {
gpx_group.removeLayer(l);
helper.side_toaster("path removed", 2000);
status.windowOpen = "map";
document.querySelector("div#finder").style.display = "none";
}
});
};

//SELECT GPX

let gpx_selection_count = 0;
Expand All @@ -375,6 +388,7 @@ const module = (() => {
gpx_group.eachLayer(function (l) {
if (l.getBounds()) gpx_selection.push(l);
});

if (gpx_selection.length == 0) {
helper.side_toaster("no gpx file to select", 2000);
return false;
Expand Down Expand Up @@ -980,7 +994,7 @@ const module = (() => {
user_input,
format_ms,
format_s,

remove_gpx,
get_closest_point,
pushLocalNotification,
uniqueId,
Expand Down
20 changes: 11 additions & 9 deletions application/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ <h2>Export</h2>
</div>

<div class="panel menu-box" name="Device position" id="coordinations">
<section id="device-position">
<section class="item" id="device-position">
<div class="lat">Lat <span></span></div>
<div class="lng">Lng <span></span></div>
<div class="altitude">Alt <span></span></div>
Expand All @@ -398,13 +398,13 @@ <h2>Export</h2>

</section>

<section id="device-distance">
<section class="item" id="device-distance">
<strong><u>Distances</u></strong>
<div class="distance">to map center <span></span></div>
<div class="target">to the goal marker <span></span></div>
</section>

<section id="device-sun">
<section class="item" id="device-sun">
<strong><u>Sun</u></strong>
<div>
<span></span>
Expand All @@ -416,18 +416,18 @@ <h2>Export</h2>
</div>

<div class="panel menu-box" name="Map center" id="mapcenter">
<section id="mapcenter-position">
<section class="item" id="mapcenter-position">
<div class="lat">Lat <span></span></div>
<div class="lng">Lng <span></span></div>
</section>

<section id="mapcenter-distance">
<section class="item" id="mapcenter-distance">
<strong><u>Distances</u></strong>
<div class="distance">to device <span></span></div>
<div class="target">to the goal marker <span></span></div>
</section>

<section id="mapcenter-sun">
<section class="item" id="mapcenter-sun">
<strong><u>Sun</u></strong>
<div>
<span></span>
Expand Down Expand Up @@ -476,14 +476,16 @@ <h2>Export</h2>
</section>
<section class="item">
<strong><u>Evolution</u></strong>
<div class="item" id="gpx-evo-up"><span></span></div>
<div class="item" id="gpx-evo-down"><span></span></div>
<div id="gpx-evo-up"><span></span></div>
<div id="gpx-evo-down"><span></span></div>
</section>
<section class="item">
<strong><u>Time</u></strong>
<div class="item" id="gpx-time">duration <span></span></div>
<div id="gpx-time">duration <span></span></div>
</section>
<button class="item" data-map="follow-path">Follow path</button>
<button class="item" data-map="remove-path">Remove path</button>

</div>
<!--ROUTING-->
<div class="panel menu-box" id="routing" name="Routing">
Expand Down
8 changes: 7 additions & 1 deletion application/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ let status = {
keylock: false,
screenOff: false,
follow_path: false,
select_gpx: false,
};

if (!navigator.geolocation) {
Expand Down Expand Up @@ -1596,6 +1597,10 @@ document.addEventListener("DOMContentLoaded", function () {
if (item_value == "resetrouting") {
rs.reset_routing();
}
if (item_value == "remove-path") {
module.remove_gpx();
}

if (item_value == "follow-path") {
if (setting.routing_notification == false) {
helper.side_toaster(
Expand Down Expand Up @@ -1911,7 +1916,8 @@ document.addEventListener("DOMContentLoaded", function () {
finder_panels = finder_panels.filter((e) => e.id != "weather");
}

if (status.select_gpx == true) {
let f = gpx_group.getLayers();
if (f.length == 0) {
finder_panels = finder_panels.filter((e) => e.id != "gpx-file-info");
}

Expand Down

0 comments on commit 13afa4c

Please sign in to comment.