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.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);
},

View File

@ -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();

View File

@ -116,6 +116,12 @@ echo '</ul>'."\n";
<option value="h"><?php p($l->t('on hover')); ?></option>
<option value="p"><?php p($l->t('permanent')); ?></option>
</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')); ?>"
for="symboloverwrite"><?php p($l->t('Use defined symbols')); ?></label>
<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', 'moment-timezone-with-data.min');
script('gpxedit', 'leaflet.draw-src');
script('gpxedit', 'leaflet.geometryutil');
//script('gpxedit', 'leaflet.geometryutil');
script('gpxedit', 'leaflet.snap');
script('gpxedit', 'Control.Draw.Plus');
script('gpxedit', 'Leaflet.LinearMeasurement');