save/restore tile layer

merge-requests/1/head
Julien Veyssier 2017-02-01 16:18:56 -03:00
parent 77023a4f28
commit f05d86a7ee
2 changed files with 15 additions and 5 deletions

View File

@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
[#10](https://gitlab.com/eneiluj/gpxedit-oc/issues/10) @eneiluj
- show animation during exporting and saving
- show saving/loading ajax percentage
- save/restore tilelayer
### Changed

View File

@ -4,6 +4,7 @@
var gpxedit = {
map: {},
baseLayers: null,
restoredTileLayer: null,
drawControl: null,
id: 0,
// indexed by gpxedit_id
@ -183,9 +184,11 @@ function load_map() {
$('meta[name=referrer]').attr('content', 'origin');
var layer = getUrlParameter('layer');
console.log('layer '+layer);
var default_layer = 'OpenStreetMap';
if (typeof layer !== 'undefined'){
if (gpxedit.restoredTileLayer !== null){
default_layer = gpxedit.restoredTileLayer;
}
else if (typeof layer !== 'undefined'){
default_layer = decodeURI(layer);
}
@ -452,6 +455,8 @@ function load_map() {
}
});
gpxedit.map.on('baselayerchange',saveOptions);
}
// called when something is drawn by hand or when a gpx is loaded
@ -1086,6 +1091,9 @@ function restoreOptions(){
if (optionsValues.symboloverwrite !== undefined){
$('#symboloverwrite').prop('checked', optionsValues.symboloverwrite);
}
if (optionsValues.tilelayer !== undefined){
gpxedit.restoredTileLayer = optionsValues.tilelayer;
}
}
function saveOptions(){
@ -1094,6 +1102,7 @@ function saveOptions(){
optionsValues.tooltipstyle = $('#tooltipstyleselect').val();
optionsValues.clearbeforeload = $('#clearbeforeload').is(':checked');
optionsValues.symboloverwrite = $('#symboloverwrite').is(':checked');
optionsValues.tilelayer = gpxedit.activeLayers.getActiveBaseLayer().name;
//alert('to save : '+JSON.stringify(optionsValues));
var req = {
@ -1185,11 +1194,11 @@ function saveAction(targetPath){
$(document).ready(function(){
gpxedit.username = $('p#username').html();
load_map();
document.onkeydown = checkKey;
addExtraSymbols();
fillWaypointStyles();
restoreOptions();
load_map();
$('select#markerstyleselect').change(function(e){
updateLeafletDrawMarkerStyle();