From 3b27b2160d4244c8bed9ecae856dcbfdc25264f9 Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Thu, 31 Aug 2017 15:50:10 +0200 Subject: [PATCH] refs #34 add 'unit' option --- js/Control.Draw.Plus.js | 8 ++++---- js/gpxedit.js | 16 +++++++++++++++- templates/gpxcontent.php | 6 ++++++ templates/main.php | 2 +- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/js/Control.Draw.Plus.js b/js/Control.Draw.Plus.js index 28d9dc1..b4216ff 100644 --- a/js/Control.Draw.Plus.js +++ b/js/Control.Draw.Plus.js @@ -35,10 +35,10 @@ L.Control.Draw.Plus = L.Control.Draw.extend({ options.edit = L.extend(this.options.edit, options.edit); // Init false non chosen options options.draw = L.extend(this.options.draw, options.draw); for (var o in options.draw) - if (options.draw[o]) - options.draw[o] = { - guideLayers: [this.snapLayers] // Allow snap on creating elements - }; + //if (options.draw[o]) + // options.draw[o] = { + // guideLayers: [this.snapLayers] // Allow snap on creating elements + // }; L.Control.Draw.prototype.initialize.call(this, options); }, diff --git a/js/gpxedit.js b/js/gpxedit.js index cd9ecb2..d9a49c8 100644 --- a/js/gpxedit.js +++ b/js/gpxedit.js @@ -371,10 +371,17 @@ //gpxedit.editableLayers = new L.FeatureGroup(); //gpxedit.map.addLayer(gpxedit.editableLayers); + var metric, feet, nautic; + var unit = $('#unitselect').val(); + metric = (unit === 'metric') ? true : false; + feet = (unit === 'feet') ? true : false; + nautic = (unit === 'nautic') ? true : false; + console.log(metric + ' ' + feet + ' ' + nautic); + var options = { position: 'bottomleft', draw: { - polyline:true, + polyline: {metric: metric, feet: feet, nautic: nautic}, polygon: false, circle: false, rectangle: false, @@ -1385,6 +1392,9 @@ if (optionsValues.tooltipstyle !== undefined) { $('#tooltipstyleselect').val(optionsValues.tooltipstyle); } + if (optionsValues.unit !== undefined) { + $('#unitselect').val(optionsValues.unit); + } if (optionsValues.clearbeforeload !== undefined) { $('#clearbeforeload').prop('checked', optionsValues.clearbeforeload); } @@ -1405,6 +1415,7 @@ var optionsValues = {}; optionsValues.markerstyle = $('#markerstyleselect').val(); optionsValues.tooltipstyle = $('#tooltipstyleselect').val(); + optionsValues.unit = $('#unitselect').val(); optionsValues.clearbeforeload = $('#clearbeforeload').is(':checked'); optionsValues.symboloverwrite = $('#symboloverwrite').is(':checked'); optionsValues.approximateele = $('#approximateele').is(':checked'); @@ -1528,6 +1539,9 @@ restoreOptions(); load_map(); + $('select#unitselect').change(function(e) { + saveOptions(); + }); $('select#markerstyleselect').change(function(e) { updateLeafletDrawMarkerStyle(); saveOptions(); diff --git a/templates/gpxcontent.php b/templates/gpxcontent.php index 7ecdfd6..6f18402 100644 --- a/templates/gpxcontent.php +++ b/templates/gpxcontent.php @@ -116,6 +116,12 @@ echo ''."\n"; + +