Skip to content

Commit

Permalink
Allow to change min zoom for POIs, closes gpxstudio#217
Browse files Browse the repository at this point in the history
  • Loading branch information
vcoppe committed Jan 31, 2023
1 parent 124804e commit 873693e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@
<option value="gray">Gray</option>
<option value="bluered">Blue-red</option>
</select><br>
<span>Choose the minimum zoom level to request POIs</span> <input id="poi-min-zoom-input" type="number" min="10" max="20"><br>
<span>Select the layers you want to appear in the interface</span>
<div id="layer-selection-area"></div>
<div id="layer-selection-ok" class="panels custom-button normal-button">Save</div>
Expand Down
20 changes: 20 additions & 0 deletions js/buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default class Buttons {
this.activity = localStorage.hasOwnProperty('activity') ? localStorage.getItem('activity') : document.getElementById('activity-input').children[0].value;
this.routing = localStorage.hasOwnProperty('routing') ? localStorage.getItem('routing') == 'true' : true;
this.strava_color = localStorage.hasOwnProperty('strava-color') ? localStorage.getItem('strava-color') : 'bluered';
this.poi_min_zoom = localStorage.hasOwnProperty('poi-min-zoom') ? parseInt(localStorage.getItem('poi-min-zoom')) : 14;
this.keep_timestamps = false;
this.disable_trace = false;
this.show_direction = false;
Expand Down Expand Up @@ -161,6 +162,7 @@ export default class Buttons {
this.activity_input = document.getElementById("activity-input");
this.routing_input = document.getElementById("routing-input");
this.strava_color_input = document.getElementById("strava-color-input");
this.poi_min_zoom_input = document.getElementById("poi-min-zoom-input");
this.units_input = document.getElementById("units-input");
this.units_text = document.getElementById("units-text");
this.speed_units_input = document.getElementById("speed-units-input");
Expand Down Expand Up @@ -1326,6 +1328,24 @@ export default class Buttons {
buttons.updateStravaColor();
});
this.strava_color_input.value = this.strava_color;
const change_poi_min_zoom = function (min_zoom) {
buttons.poi_min_zoom = min_zoom;
localStorage.setItem('poi-min-zoom', min_zoom);
Object.keys(layers).forEach(function(layer) {
if (layer.startsWith('poi')) {
layers[layer].options.minZoom = buttons.poi_min_zoom;
if (buttons.map.hasLayer(layers[layer])) {
buttons.map.removeLayer(layers[layer]);
buttons.map.addLayer(layers[layer]);
}
}
});
}
this.poi_min_zoom_input.addEventListener("change", function (e) {
change_poi_min_zoom(buttons.poi_min_zoom_input.value);
});
this.poi_min_zoom_input.value = this.poi_min_zoom;
change_poi_min_zoom(this.poi_min_zoom);
const editing_time_option = function () {
buttons.keep_timestamps = buttons.edit_keep_time.checked;
};
Expand Down

0 comments on commit 873693e

Please sign in to comment.