refs #34 add 'unit' option

merge-requests/3/head
Julien Veyssier 2017-08-31 15:50:10 +02:00
parent 01ea989345
commit 3b27b2160d
4 changed files with 26 additions and 6 deletions

View File

@ -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.edit = L.extend(this.options.edit, options.edit); // Init false non chosen options
options.draw = L.extend(this.options.draw, options.draw); options.draw = L.extend(this.options.draw, options.draw);
for (var o in options.draw) for (var o in options.draw)
if (options.draw[o]) //if (options.draw[o])
options.draw[o] = { // options.draw[o] = {
guideLayers: [this.snapLayers] // Allow snap on creating elements // guideLayers: [this.snapLayers] // Allow snap on creating elements
}; // };
L.Control.Draw.prototype.initialize.call(this, options); L.Control.Draw.prototype.initialize.call(this, options);
}, },

View File

@ -371,10 +371,17 @@
//gpxedit.editableLayers = new L.FeatureGroup(); //gpxedit.editableLayers = new L.FeatureGroup();
//gpxedit.map.addLayer(gpxedit.editableLayers); //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 = { var options = {
position: 'bottomleft', position: 'bottomleft',
draw: { draw: {
polyline:true, polyline: {metric: metric, feet: feet, nautic: nautic},
polygon: false, polygon: false,
circle: false, circle: false,
rectangle: false, rectangle: false,
@ -1385,6 +1392,9 @@
if (optionsValues.tooltipstyle !== undefined) { if (optionsValues.tooltipstyle !== undefined) {
$('#tooltipstyleselect').val(optionsValues.tooltipstyle); $('#tooltipstyleselect').val(optionsValues.tooltipstyle);
} }
if (optionsValues.unit !== undefined) {
$('#unitselect').val(optionsValues.unit);
}
if (optionsValues.clearbeforeload !== undefined) { if (optionsValues.clearbeforeload !== undefined) {
$('#clearbeforeload').prop('checked', optionsValues.clearbeforeload); $('#clearbeforeload').prop('checked', optionsValues.clearbeforeload);
} }
@ -1405,6 +1415,7 @@
var optionsValues = {}; var optionsValues = {};
optionsValues.markerstyle = $('#markerstyleselect').val(); optionsValues.markerstyle = $('#markerstyleselect').val();
optionsValues.tooltipstyle = $('#tooltipstyleselect').val(); optionsValues.tooltipstyle = $('#tooltipstyleselect').val();
optionsValues.unit = $('#unitselect').val();
optionsValues.clearbeforeload = $('#clearbeforeload').is(':checked'); optionsValues.clearbeforeload = $('#clearbeforeload').is(':checked');
optionsValues.symboloverwrite = $('#symboloverwrite').is(':checked'); optionsValues.symboloverwrite = $('#symboloverwrite').is(':checked');
optionsValues.approximateele = $('#approximateele').is(':checked'); optionsValues.approximateele = $('#approximateele').is(':checked');
@ -1528,6 +1539,9 @@
restoreOptions(); restoreOptions();
load_map(); load_map();
$('select#unitselect').change(function(e) {
saveOptions();
});
$('select#markerstyleselect').change(function(e) { $('select#markerstyleselect').change(function(e) {
updateLeafletDrawMarkerStyle(); updateLeafletDrawMarkerStyle();
saveOptions(); saveOptions();

View File

@ -116,6 +116,12 @@ echo '</ul>'."\n";
<option value="h"><?php p($l->t('on hover')); ?></option> <option value="h"><?php p($l->t('on hover')); ?></option>
<option value="p"><?php p($l->t('permanent')); ?></option> <option value="p"><?php p($l->t('permanent')); ?></option>
</select> </select>
<label for="unitselect"><?php p($l->t('Units (needs page reload to take effect)'));?>:</label>
<select id="unitselect">
<option value="metric"><?php p($l->t('Metric')); ?></option>
<option value="feet"><?php p($l->t('English')); ?></option>
<option value="nautic"><?php p($l->t('Nautical')); ?></option>
</select>
<label title="<?php p($l->t('Use defined symbols instead of default symbol')); ?>" <label title="<?php p($l->t('Use defined symbols instead of default symbol')); ?>"
for="symboloverwrite"><?php p($l->t('Use defined symbols')); ?></label> for="symboloverwrite"><?php p($l->t('Use defined symbols')); ?></label>
<input title="<?php p($l->t('Use defined symbols instead of default symbol')); ?>" <input title="<?php p($l->t('Use defined symbols instead of default symbol')); ?>"

View File

@ -12,7 +12,7 @@ script('gpxedit', 'detect_timezone');
script('gpxedit', 'jquery.detect_timezone'); script('gpxedit', 'jquery.detect_timezone');
script('gpxedit', 'moment-timezone-with-data.min'); script('gpxedit', 'moment-timezone-with-data.min');
script('gpxedit', 'leaflet.draw-src'); script('gpxedit', 'leaflet.draw-src');
script('gpxedit', 'leaflet.geometryutil'); //script('gpxedit', 'leaflet.geometryutil');
script('gpxedit', 'leaflet.snap'); script('gpxedit', 'leaflet.snap');
script('gpxedit', 'Control.Draw.Plus'); script('gpxedit', 'Control.Draw.Plus');
script('gpxedit', 'Leaflet.LinearMeasurement'); script('gpxedit', 'Leaflet.LinearMeasurement');