Increase prettier maxwidth to 120
This commit is contained in:
parent
ce9e34283b
commit
d31be926d2
27 changed files with 248 additions and 956 deletions
|
|
@ -6,9 +6,7 @@
|
|||
result = navigator.maxTouchPoints > 0;
|
||||
} else if (
|
||||
window.matchMedia &&
|
||||
window.matchMedia(
|
||||
'(any-pointer:coarse),(any-pointer:fine),(any-pointer:none)'
|
||||
).matches
|
||||
window.matchMedia('(any-pointer:coarse),(any-pointer:fine),(any-pointer:none)').matches
|
||||
) {
|
||||
result = window.matchMedia('(any-pointer:coarse)').matches;
|
||||
} else if ('msMaxTouchPoints' in navigator) {
|
||||
|
|
|
|||
|
|
@ -29,10 +29,7 @@ BR.LayersConfig = L.Class.extend({
|
|||
baseLayers: baseLayers,
|
||||
overlays: overlays
|
||||
};
|
||||
localStorage.setItem(
|
||||
'map/defaultLayers',
|
||||
JSON.stringify(defaultLayers)
|
||||
);
|
||||
localStorage.setItem('map/defaultLayers', JSON.stringify(defaultLayers));
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -75,8 +72,7 @@ BR.LayersConfig = L.Class.extend({
|
|||
BR.layerIndex['MtbMap'].geometry = BR.confLayers.europeGeofabrik;
|
||||
BR.layerIndex['1069'].geometry = BR.confLayers.europeGeofabrik;
|
||||
|
||||
BR.layerIndex['OpenStreetMap.CH'].geometry =
|
||||
BR.confLayers.switzerlandPadded;
|
||||
BR.layerIndex['OpenStreetMap.CH'].geometry = BR.confLayers.switzerlandPadded;
|
||||
|
||||
BR.layerIndex['1017'].geometry = BR.confLayers.osmapaPl;
|
||||
},
|
||||
|
|
@ -138,9 +134,7 @@ BR.LayersConfig = L.Class.extend({
|
|||
// when key required only add if configured
|
||||
var keyObj = this.getKeyName(layerData.properties.url);
|
||||
if (!keyObj || (keyObj && BR.keys[keyObj.name])) {
|
||||
layers[layerData.properties.name] = this.createLayer(
|
||||
layerData
|
||||
);
|
||||
layers[layerData.properties.name] = this.createLayer(layerData);
|
||||
}
|
||||
} else {
|
||||
console.error('Layer not found: ' + layerId);
|
||||
|
|
@ -208,12 +202,7 @@ BR.LayersConfig = L.Class.extend({
|
|||
if (attr.html) {
|
||||
result = attr.html;
|
||||
} else if (attr.url && attr.text) {
|
||||
result =
|
||||
'<a href="' +
|
||||
attr.url +
|
||||
'" target="_blank" rel="noopener">' +
|
||||
attr.text +
|
||||
'</a>';
|
||||
result = '<a href="' + attr.url + '" target="_blank" rel="noopener">' + attr.text + '</a>';
|
||||
} else if (attr.text) {
|
||||
result = attr.text;
|
||||
}
|
||||
|
|
@ -227,18 +216,11 @@ BR.LayersConfig = L.Class.extend({
|
|||
|
||||
var options = {
|
||||
maxZoom: this._map.getMaxZoom(),
|
||||
bounds:
|
||||
layerData.geometry && !props.worldTiles
|
||||
? L.geoJson(layerData.geometry).getBounds()
|
||||
: null
|
||||
bounds: layerData.geometry && !props.worldTiles ? L.geoJson(layerData.geometry).getBounds() : null
|
||||
};
|
||||
if (props.mapUrl) {
|
||||
options.mapLink =
|
||||
'<a target="_blank" href="' +
|
||||
props.mapUrl +
|
||||
'">' +
|
||||
(props.nameShort || props.name) +
|
||||
'</a>';
|
||||
'<a target="_blank" href="' + props.mapUrl + '">' + (props.nameShort || props.name) + '</a>';
|
||||
}
|
||||
if (props.attribution) {
|
||||
options.attribution = props.attribution;
|
||||
|
|
|
|||
13
js/Map.js
13
js/Map.js
|
|
@ -52,9 +52,7 @@ BR.Map = {
|
|||
var overlays = layersConfig.getOverlays();
|
||||
|
||||
if (BR.keys.bing) {
|
||||
baseLayers[i18next.t('map.layer.bing')] = new BR.BingLayer(
|
||||
BR.keys.bing
|
||||
);
|
||||
baseLayers[i18next.t('map.layer.bing')] = new BR.BingLayer(BR.keys.bing);
|
||||
}
|
||||
|
||||
if (BR.keys.digitalGlobe) {
|
||||
|
|
@ -86,14 +84,9 @@ BR.Map = {
|
|||
}
|
||||
}
|
||||
|
||||
layersControl = BR.layersTab(layersConfig, baseLayers, overlays).addTo(
|
||||
map
|
||||
);
|
||||
layersControl = BR.layersTab(layersConfig, baseLayers, overlays).addTo(map);
|
||||
|
||||
var secureContext =
|
||||
'isSecureContext' in window
|
||||
? isSecureContext
|
||||
: location.protocol === 'https:';
|
||||
var secureContext = 'isSecureContext' in window ? isSecureContext : location.protocol === 'https:';
|
||||
if (secureContext) {
|
||||
L.control
|
||||
.locate({
|
||||
|
|
|
|||
|
|
@ -8,19 +8,12 @@ BR.Export = L.Class.extend({
|
|||
this.tracknameAllowedChars = BR.conf.tracknameAllowedChars;
|
||||
|
||||
if (this.tracknameAllowedChars) {
|
||||
this.tracknameMessage = document.getElementById(
|
||||
'trackname-message'
|
||||
);
|
||||
var patternRegex = new RegExp(
|
||||
'[' + this.tracknameAllowedChars + ']+'
|
||||
);
|
||||
this.tracknameMessage = document.getElementById('trackname-message');
|
||||
var patternRegex = new RegExp('[' + this.tracknameAllowedChars + ']+');
|
||||
|
||||
// warn about special characters getting removed by server quick fix (#194)
|
||||
trackname.pattern = patternRegex.toString().slice(1, -1);
|
||||
trackname.addEventListener(
|
||||
'input',
|
||||
L.bind(this._validationMessage, this)
|
||||
);
|
||||
trackname.addEventListener('input', L.bind(this._validationMessage, this));
|
||||
}
|
||||
|
||||
this.exportButton.on('click', L.bind(this._generateTrackname, this));
|
||||
|
|
@ -41,37 +34,14 @@ BR.Export = L.Class.extend({
|
|||
|
||||
_export: function() {
|
||||
var exportForm = document.forms['export'];
|
||||
var format =
|
||||
exportForm['format'].value ||
|
||||
$('#export-format input:radio:checked').val();
|
||||
var format = exportForm['format'].value || $('#export-format input:radio:checked').val();
|
||||
var name = encodeURIComponent(exportForm['trackname'].value);
|
||||
var includeWaypoints = exportForm['include-waypoints'].checked;
|
||||
|
||||
var uri = this.router.getUrl(
|
||||
this.latLngs,
|
||||
format,
|
||||
name,
|
||||
includeWaypoints
|
||||
);
|
||||
var uri = this.router.getUrl(this.latLngs, format, name, includeWaypoints);
|
||||
|
||||
var evt = document.createEvent('MouseEvents');
|
||||
evt.initMouseEvent(
|
||||
'click',
|
||||
true,
|
||||
true,
|
||||
window,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
0,
|
||||
null
|
||||
);
|
||||
evt.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
|
||||
var link = document.createElement('a');
|
||||
link.href = uri;
|
||||
link.dispatchEvent(evt);
|
||||
|
|
@ -79,16 +49,12 @@ BR.Export = L.Class.extend({
|
|||
|
||||
_validationMessage: function() {
|
||||
var trackname = this.trackname;
|
||||
var replaceRegex = new RegExp(
|
||||
'[^' + this.tracknameAllowedChars + ']',
|
||||
'g'
|
||||
);
|
||||
var replaceRegex = new RegExp('[^' + this.tracknameAllowedChars + ']', 'g');
|
||||
|
||||
if (trackname.validity.patternMismatch) {
|
||||
var replaced = trackname.value.replace(replaceRegex, '');
|
||||
var patternStr = this.tracknameAllowedChars.replace(/\\/g, '');
|
||||
this.tracknameMessage.textContent =
|
||||
'[' + patternStr + '] --> ' + replaced;
|
||||
this.tracknameMessage.textContent = '[' + patternStr + '] --> ' + replaced;
|
||||
} else {
|
||||
this.tracknameMessage.textContent = '';
|
||||
}
|
||||
|
|
@ -102,8 +68,7 @@ BR.Export = L.Class.extend({
|
|||
this._getCityAtPosition(
|
||||
this.latLngs[this.latLngs.length - 1],
|
||||
L.bind(function(to) {
|
||||
var distance = document.getElementById('distance')
|
||||
.innerHTML;
|
||||
var distance = document.getElementById('distance').innerHTML;
|
||||
if (this.tracknameAllowedChars) {
|
||||
distance = distance.replace(',', '.'); // temp. fix (#202)
|
||||
}
|
||||
|
|
@ -115,17 +80,16 @@ BR.Export = L.Class.extend({
|
|||
distance: distance
|
||||
});
|
||||
} else {
|
||||
trackname.value = i18next.t(
|
||||
'export.route-from-to',
|
||||
{ from: from, to: to, distance: distance }
|
||||
);
|
||||
trackname.value = i18next.t('export.route-from-to', {
|
||||
from: from,
|
||||
to: to,
|
||||
distance: distance
|
||||
});
|
||||
}
|
||||
|
||||
if (this.tracknameAllowedChars) {
|
||||
// temp. fix: replace and remove characters that will get removed by server quick fix (#194)
|
||||
trackname.value = trackname.value
|
||||
.replace(/[>)]/g, '')
|
||||
.replace(/ \(/g, ' - ');
|
||||
trackname.value = trackname.value.replace(/[>)]/g, '').replace(/ \(/g, ' - ');
|
||||
this._validationMessage();
|
||||
}
|
||||
}, this)
|
||||
|
|
@ -144,17 +108,9 @@ BR.Export = L.Class.extend({
|
|||
L.bind(function(err, response) {
|
||||
try {
|
||||
var addr = JSON.parse(response).address;
|
||||
cb(
|
||||
addr.village ||
|
||||
addr.town ||
|
||||
addr.hamlet ||
|
||||
addr.city_district ||
|
||||
addr.city
|
||||
);
|
||||
cb(addr.village || addr.town || addr.hamlet || addr.city_district || addr.city);
|
||||
} catch (err) {
|
||||
BR.message.showError(
|
||||
'Error getting position city "' + lonlat + '": ' + err
|
||||
);
|
||||
BR.message.showError('Error getting position city "' + lonlat + '": ' + err);
|
||||
return cb(null);
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -46,18 +46,9 @@ BR.Layers = L.Class.extend({
|
|||
for (var l in overlays) this._layers[l] = [overlays[l], true];
|
||||
for (var l in baseLayers) this._layers[l] = [baseLayers[l], false];
|
||||
|
||||
L.DomUtil.get('custom_layers_add_base').onclick = L.bind(
|
||||
this._addBaseLayer,
|
||||
this
|
||||
);
|
||||
L.DomUtil.get('custom_layers_add_overlay').onclick = L.bind(
|
||||
this._addOverlay,
|
||||
this
|
||||
);
|
||||
L.DomUtil.get('custom_layers_remove').onclick = L.bind(
|
||||
this._remove,
|
||||
this
|
||||
);
|
||||
L.DomUtil.get('custom_layers_add_base').onclick = L.bind(this._addBaseLayer, this);
|
||||
L.DomUtil.get('custom_layers_add_overlay').onclick = L.bind(this._addOverlay, this);
|
||||
L.DomUtil.get('custom_layers_remove').onclick = L.bind(this._remove, this);
|
||||
|
||||
this._loadLayers();
|
||||
this._loadTable();
|
||||
|
|
@ -95,8 +86,7 @@ BR.Layers = L.Class.extend({
|
|||
_addFromInput: function(isOverlay) {
|
||||
var layer_name = L.DomUtil.get('layer_name').value;
|
||||
var layer_url = L.DomUtil.get('layer_url').value;
|
||||
if (layer_name.length > 0 && layer_url.length > 0)
|
||||
this._addLayer(layer_name, layer_url, isOverlay);
|
||||
if (layer_name.length > 0 && layer_url.length > 0) this._addLayer(layer_name, layer_url, isOverlay);
|
||||
},
|
||||
|
||||
_addBaseLayer: function(evt) {
|
||||
|
|
|
|||
|
|
@ -4,12 +4,7 @@ BR.LayersTab = BR.ControlLayers.extend({
|
|||
saveLayers: [],
|
||||
|
||||
initialize: function(layersConfig, baseLayers, overlays, options) {
|
||||
L.Control.Layers.prototype.initialize.call(
|
||||
this,
|
||||
baseLayers,
|
||||
overlays,
|
||||
options
|
||||
);
|
||||
L.Control.Layers.prototype.initialize.call(this, baseLayers, overlays, options);
|
||||
|
||||
this.layersConfig = layersConfig;
|
||||
},
|
||||
|
|
@ -30,21 +25,13 @@ BR.LayersTab = BR.ControlLayers.extend({
|
|||
onAdd: function(map) {
|
||||
BR.ControlLayers.prototype.onAdd.call(this, map);
|
||||
|
||||
map.on(
|
||||
'baselayerchange overlayadd overlayremove',
|
||||
this.storeActiveLayers,
|
||||
this
|
||||
);
|
||||
map.on('baselayerchange overlayadd overlayremove', this.storeActiveLayers, this);
|
||||
},
|
||||
|
||||
onRemove: function(map) {
|
||||
BR.ControlLayers.prototype.onRemove.call(this, map);
|
||||
|
||||
map.off(
|
||||
'baselayerchange overlayadd overlayremove',
|
||||
this.storeActiveLayers,
|
||||
this
|
||||
);
|
||||
map.off('baselayerchange overlayadd overlayremove', this.storeActiveLayers, this);
|
||||
},
|
||||
|
||||
initOpacitySlider: function(map) {
|
||||
|
|
@ -57,19 +44,14 @@ BR.LayersTab = BR.ControlLayers.extend({
|
|||
title: i18next.t('layers.opacity-slider'),
|
||||
callback: function(opacity) {
|
||||
for (var i = 0; i < self._layers.length; i++) {
|
||||
if (
|
||||
!self._layers[i].overlay ||
|
||||
!map.hasLayer(self._layers[i].layer)
|
||||
) {
|
||||
if (!self._layers[i].overlay || !map.hasLayer(self._layers[i].layer)) {
|
||||
continue;
|
||||
}
|
||||
self._layers[i].layer.setOpacity(opacity);
|
||||
}
|
||||
}
|
||||
});
|
||||
L.DomUtil.get(
|
||||
'leaflet-control-layers-overlays-opacity-slider'
|
||||
).appendChild(overlayOpacitySlider.getElement());
|
||||
L.DomUtil.get('leaflet-control-layers-overlays-opacity-slider').appendChild(overlayOpacitySlider.getElement());
|
||||
},
|
||||
|
||||
initButtons: function() {
|
||||
|
|
@ -95,15 +77,9 @@ BR.LayersTab = BR.ControlLayers.extend({
|
|||
};
|
||||
|
||||
L.DomUtil.get('expand_tree_button').onclick = L.bind(expandTree, this);
|
||||
L.DomUtil.get('collapse_tree_button').onclick = L.bind(
|
||||
collapseTree,
|
||||
this
|
||||
);
|
||||
L.DomUtil.get('collapse_tree_button').onclick = L.bind(collapseTree, this);
|
||||
|
||||
L.DomUtil.get('optional_layers_button').onclick = L.bind(
|
||||
toggleOptionalLayers,
|
||||
this
|
||||
);
|
||||
L.DomUtil.get('optional_layers_button').onclick = L.bind(toggleOptionalLayers, this);
|
||||
},
|
||||
|
||||
initJsTree: function() {
|
||||
|
|
@ -225,10 +201,7 @@ BR.LayersTab = BR.ControlLayers.extend({
|
|||
id: id,
|
||||
text: getText(props, parent),
|
||||
state: {
|
||||
checked: self.layersConfig.isDefaultLayer(
|
||||
id,
|
||||
props.overlay
|
||||
)
|
||||
checked: self.layersConfig.isDefaultLayer(id, props.overlay)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,10 +12,7 @@ BR.Message = L.Class.extend({
|
|||
|
||||
_show: function(msg, type) {
|
||||
var ele = L.DomUtil.get(this.id),
|
||||
iconClass =
|
||||
type === 'warning'
|
||||
? 'fa-exclamation-triangle'
|
||||
: 'fa-times-circle',
|
||||
iconClass = type === 'warning' ? 'fa-exclamation-triangle' : 'fa-times-circle',
|
||||
alertClass = type === 'warning' ? 'alert-warning' : 'alert-danger';
|
||||
|
||||
L.DomEvent.disableClickPropagation(ele);
|
||||
|
|
|
|||
|
|
@ -11,12 +11,8 @@ BR.OpacitySlider = L.Class.extend({
|
|||
initialize: function(options) {
|
||||
L.setOptions(this, options);
|
||||
|
||||
var input = (this.input = $(
|
||||
'<input id="slider-' + this.options.id + '" type="text"/>'
|
||||
)),
|
||||
item = BR.Util.localStorageAvailable()
|
||||
? localStorage['opacitySliderValue' + this.options.id]
|
||||
: null,
|
||||
var input = (this.input = $('<input id="slider-' + this.options.id + '" type="text"/>')),
|
||||
item = BR.Util.localStorageAvailable() ? localStorage['opacitySliderValue' + this.options.id] : null,
|
||||
value = item ? parseInt(item) : this.options.defaultValue * 100,
|
||||
minOpacity = (BR.conf.minOpacity || 0) * 100;
|
||||
|
||||
|
|
@ -41,9 +37,7 @@ BR.OpacitySlider = L.Class.extend({
|
|||
})
|
||||
.on('slideStop', { self: this }, function(evt) {
|
||||
if (BR.Util.localStorageAvailable()) {
|
||||
localStorage[
|
||||
'opacitySliderValue' + evt.data.self.options.id
|
||||
] = evt.value;
|
||||
localStorage['opacitySliderValue' + evt.data.self.options.id] = evt.value;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -13,10 +13,7 @@ BR.OpacitySliderControl = L.Control.extend({
|
|||
if (BR.Util.localStorageAvailable()) {
|
||||
var value = localStorage.getItem('opacitySliderValue');
|
||||
if (value !== null) {
|
||||
localStorage.setItem(
|
||||
'opacitySliderValue' + this.options.id,
|
||||
value
|
||||
);
|
||||
localStorage.setItem('opacitySliderValue' + this.options.id, value);
|
||||
localStorage.removeItem('opacitySliderValue');
|
||||
}
|
||||
}
|
||||
|
|
@ -31,11 +28,7 @@ BR.OpacitySliderControl = L.Control.extend({
|
|||
|
||||
var removeStopClickListeners = function() {
|
||||
document.removeEventListener('click', stopClickAfterSlide, true);
|
||||
document.removeEventListener(
|
||||
'mousedown',
|
||||
removeStopClickListeners,
|
||||
true
|
||||
);
|
||||
document.removeEventListener('mousedown', removeStopClickListeners, true);
|
||||
};
|
||||
|
||||
slider.input
|
||||
|
|
@ -52,11 +45,7 @@ BR.OpacitySliderControl = L.Control.extend({
|
|||
document.addEventListener('click', stopClickAfterSlide, true);
|
||||
// Firefox does not fire click event in this case, so make sure stop listener
|
||||
// is always removed on next mousedown.
|
||||
document.addEventListener(
|
||||
'mousedown',
|
||||
removeStopClickListeners,
|
||||
true
|
||||
);
|
||||
document.addEventListener('mousedown', removeStopClickListeners, true);
|
||||
});
|
||||
|
||||
return container;
|
||||
|
|
|
|||
|
|
@ -39,22 +39,14 @@ BR.Profile = L.Evented.extend({
|
|||
profileUrl,
|
||||
L.bind(function(err, profileText) {
|
||||
if (err) {
|
||||
console.warn(
|
||||
'Error getting profile from "' +
|
||||
profileUrl +
|
||||
'": ' +
|
||||
err
|
||||
);
|
||||
console.warn('Error getting profile from "' + profileUrl + '": ' + err);
|
||||
return;
|
||||
}
|
||||
|
||||
this.cache[profileName] = profileText;
|
||||
|
||||
// don't set when option has changed while loading
|
||||
if (
|
||||
!this.profileName ||
|
||||
this.profileName === profileName
|
||||
) {
|
||||
if (!this.profileName || this.profileName === profileName) {
|
||||
this._setValue(profileText);
|
||||
}
|
||||
}, this)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
BR.RoutingOptions = L.Evented.extend({
|
||||
initialize: function() {
|
||||
$('#profile-alternative').on(
|
||||
'changed.bs.select',
|
||||
this._getChangeHandler()
|
||||
);
|
||||
$('#profile-alternative').on('changed.bs.select', this._getChangeHandler());
|
||||
|
||||
// build option list from config
|
||||
var profiles = BR.conf.profiles;
|
||||
|
|
@ -55,12 +52,8 @@ BR.RoutingOptions = L.Evented.extend({
|
|||
|
||||
setOptions: function(options) {
|
||||
var values = [
|
||||
options.profile
|
||||
? options.profile
|
||||
: $('#profile option:selected').val(),
|
||||
options.alternative
|
||||
? options.alternative
|
||||
: $('#alternative option:selected').val()
|
||||
options.profile ? options.profile : $('#profile option:selected').val(),
|
||||
options.alternative ? options.alternative : $('#alternative option:selected').val()
|
||||
];
|
||||
$('.selectpicker').selectpicker('val', values);
|
||||
this.refreshUI();
|
||||
|
|
|
|||
|
|
@ -74,10 +74,7 @@ BR.TrackMessages = L.Class.extend({
|
|||
|
||||
// highlight track segment (graph edge) on row hover
|
||||
this._setEdges(polyline, segments);
|
||||
$('#datatable tbody tr').hover(
|
||||
L.bind(this._handleHover, this),
|
||||
L.bind(this._handleHoverOut, this)
|
||||
);
|
||||
$('#datatable tbody tr').hover(L.bind(this._handleHover, this), L.bind(this._handleHoverOut, this));
|
||||
},
|
||||
|
||||
show: function() {
|
||||
|
|
@ -198,10 +195,7 @@ BR.TrackMessages = L.Class.extend({
|
|||
endIndex = this._edges[row.index()],
|
||||
edgeLatLngs = trackLatLngs.slice(startIndex, endIndex + 1);
|
||||
|
||||
this._selectedEdge = L.polyline(
|
||||
edgeLatLngs,
|
||||
this.options.edgeStyle
|
||||
).addTo(this._map);
|
||||
this._selectedEdge = L.polyline(edgeLatLngs, this.options.edgeStyle).addTo(this._map);
|
||||
},
|
||||
|
||||
_handleHoverOut: function(evt) {
|
||||
|
|
|
|||
|
|
@ -14,36 +14,19 @@ BR.TrackStats = L.Class.extend({
|
|||
}
|
||||
|
||||
var stats = this.calcStats(polyline, segments),
|
||||
length1 = L.Util.formatNum(
|
||||
stats.trackLength / 1000,
|
||||
1
|
||||
).toLocaleString(),
|
||||
length3 = L.Util.formatNum(
|
||||
stats.trackLength / 1000,
|
||||
3
|
||||
).toLocaleString(),
|
||||
length1 = L.Util.formatNum(stats.trackLength / 1000, 1).toLocaleString(),
|
||||
length3 = L.Util.formatNum(stats.trackLength / 1000, 3).toLocaleString(),
|
||||
formattedAscend = stats.filteredAscend.toLocaleString(),
|
||||
formattedPlainAscend = stats.plainAscend.toLocaleString(),
|
||||
formattedCost = stats.cost.toLocaleString(),
|
||||
meanCostFactor = stats.trackLength
|
||||
? L.Util.formatNum(
|
||||
stats.cost / stats.trackLength,
|
||||
2
|
||||
).toLocaleString()
|
||||
? L.Util.formatNum(stats.cost / stats.trackLength, 2).toLocaleString()
|
||||
: '0',
|
||||
formattedTime =
|
||||
Math.trunc(stats.totalTime / 3600) +
|
||||
':' +
|
||||
('0' + Math.trunc((stats.totalTime % 3600) / 60)).slice(-2),
|
||||
formattedEnergy = L.Util.formatNum(
|
||||
stats.totalEnergy / 3600000,
|
||||
2
|
||||
).toLocaleString(),
|
||||
Math.trunc(stats.totalTime / 3600) + ':' + ('0' + Math.trunc((stats.totalTime % 3600) / 60)).slice(-2),
|
||||
formattedEnergy = L.Util.formatNum(stats.totalEnergy / 3600000, 2).toLocaleString(),
|
||||
meanEnergy = stats.trackLength
|
||||
? L.Util.formatNum(
|
||||
stats.totalEnergy / 36 / stats.trackLength,
|
||||
2
|
||||
).toLocaleString()
|
||||
? L.Util.formatNum(stats.totalEnergy / 36 / stats.trackLength, 2).toLocaleString()
|
||||
: '0';
|
||||
|
||||
$('#distance').html(length1);
|
||||
|
|
|
|||
39
js/index.js
39
js/index.js
|
|
@ -10,15 +10,8 @@
|
|||
function verifyTouchStyle(mapContext) {
|
||||
// revert touch style (large icons) when touch screen detection is available and negative
|
||||
// see https://github.com/nrenner/brouter-web/issues/69
|
||||
if (
|
||||
L.Browser.touch &&
|
||||
BR.Browser.touchScreenDetectable &&
|
||||
!BR.Browser.touchScreen
|
||||
) {
|
||||
L.DomUtil.removeClass(
|
||||
mapContext.map.getContainer(),
|
||||
'leaflet-touch'
|
||||
);
|
||||
if (L.Browser.touch && BR.Browser.touchScreenDetectable && !BR.Browser.touchScreen) {
|
||||
L.DomUtil.removeClass(mapContext.map.getContainer(), 'leaflet-touch');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -91,10 +84,7 @@
|
|||
deletePointButton = L.easyButton(
|
||||
'<span><i class="fa fa-caret-left"></i><i class="fa fa-map-marker" style="margin-left: 1px; color: gray;"></i></span>',
|
||||
function() {
|
||||
routing.removeWaypoint(routing.getLast(), function(
|
||||
err,
|
||||
data
|
||||
) {});
|
||||
routing.removeWaypoint(routing.getLast(), function(err, data) {});
|
||||
},
|
||||
i18next.t('map.delete-last-point')
|
||||
);
|
||||
|
|
@ -171,19 +161,14 @@
|
|||
profile.on('update', function(evt) {
|
||||
BR.message.hide();
|
||||
var profileId = routingOptions.getCustomProfile();
|
||||
router.uploadProfile(profileId, evt.profileText, function(
|
||||
err,
|
||||
profileId
|
||||
) {
|
||||
router.uploadProfile(profileId, evt.profileText, function(err, profileId) {
|
||||
if (!err) {
|
||||
routingOptions.setCustomProfile(profileId, true);
|
||||
updateRoute({
|
||||
options: routingOptions.getOptions()
|
||||
});
|
||||
if (!saveWarningShown) {
|
||||
profile.message.showWarning(
|
||||
i18next.t('warning.temporary-profile')
|
||||
);
|
||||
profile.message.showWarning(i18next.t('warning.temporary-profile'));
|
||||
saveWarningShown = true;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -214,9 +199,7 @@
|
|||
styles: BR.conf.routingStyles
|
||||
});
|
||||
|
||||
routing.on('routing:routeWaypointEnd routing:setWaypointsEnd', function(
|
||||
evt
|
||||
) {
|
||||
routing.on('routing:routeWaypointEnd routing:setWaypointsEnd', function(evt) {
|
||||
search.clear();
|
||||
onUpdate(evt && evt.err);
|
||||
});
|
||||
|
|
@ -339,9 +322,7 @@
|
|||
// do not initialize immediately
|
||||
urlHash = new L.Hash(null, null);
|
||||
urlHash.additionalCb = function() {
|
||||
var url = router
|
||||
.getUrl(routing.getWaypoints(), null)
|
||||
.substr('brouter?'.length + 1);
|
||||
var url = router.getUrl(routing.getWaypoints(), null).substr('brouter?'.length + 1);
|
||||
url = url.replace(/\|/g, ';');
|
||||
return url.length > 0 ? '&' + url : null;
|
||||
};
|
||||
|
|
@ -401,11 +382,7 @@
|
|||
.on('hidden.bs.collapse', onHide)
|
||||
.on('shown.bs.collapse', onShow)
|
||||
.each(function() {
|
||||
if (
|
||||
this.id &&
|
||||
BR.Util.localStorageAvailable() &&
|
||||
localStorage[this.id] === 'true'
|
||||
) {
|
||||
if (this.id && BR.Util.localStorageAvailable() && localStorage[this.id] === 'true') {
|
||||
$(this).collapse('show');
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -15,33 +15,19 @@ BR.Elevation = L.Control.Elevation.extend({
|
|||
|
||||
// revert registering touch events when touch screen detection is available and negative
|
||||
// see https://github.com/MrMufflon/Leaflet.Elevation/issues/67
|
||||
if (
|
||||
L.Browser.touch &&
|
||||
BR.Browser.touchScreenDetectable &&
|
||||
!BR.Browser.touchScreen
|
||||
) {
|
||||
if (L.Browser.touch && BR.Browser.touchScreenDetectable && !BR.Browser.touchScreen) {
|
||||
this._background
|
||||
.on('touchmove.drag', null)
|
||||
.on('touchstart.drag', null)
|
||||
.on('touchstart.focus', null);
|
||||
L.DomEvent.off(
|
||||
this._container,
|
||||
'touchend',
|
||||
this._dragEndHandler,
|
||||
this
|
||||
);
|
||||
L.DomEvent.off(this._container, 'touchend', this._dragEndHandler, this);
|
||||
|
||||
this._background
|
||||
.on('mousemove.focus', this._mousemoveHandler.bind(this))
|
||||
.on('mouseout.focus', this._mouseoutHandler.bind(this))
|
||||
.on('mousedown.drag', this._dragStartHandler.bind(this))
|
||||
.on('mousemove.drag', this._dragHandler.bind(this));
|
||||
L.DomEvent.on(
|
||||
this._container,
|
||||
'mouseup',
|
||||
this._dragEndHandler,
|
||||
this
|
||||
);
|
||||
L.DomEvent.on(this._container, 'mouseup', this._dragEndHandler, this);
|
||||
}
|
||||
|
||||
return container;
|
||||
|
|
@ -61,10 +47,7 @@ BR.Elevation = L.Control.Elevation.extend({
|
|||
}
|
||||
this.addTo(map);
|
||||
// move elevation graph outside of the map
|
||||
setParent(
|
||||
this.getContainer(),
|
||||
document.getElementById('elevation-chart')
|
||||
);
|
||||
setParent(this.getContainer(), document.getElementById('elevation-chart'));
|
||||
},
|
||||
|
||||
update: function(track, layer) {
|
||||
|
|
|
|||
|
|
@ -143,9 +143,7 @@ BR.NogoAreas = L.Control.extend({
|
|||
resolve(reader.result);
|
||||
};
|
||||
reader.onerror = function() {
|
||||
self.displayUploadError(
|
||||
'Could not load file: ' + reader.error.message
|
||||
);
|
||||
self.displayUploadError('Could not load file: ' + reader.error.message);
|
||||
};
|
||||
|
||||
reader.readAsText(nogoFile);
|
||||
|
|
@ -184,32 +182,22 @@ BR.NogoAreas = L.Control.extend({
|
|||
var maybeBufferedFeature = feature;
|
||||
// Eventually buffer GeoJSON
|
||||
if (nogoBuffer !== 0) {
|
||||
maybeBufferedFeature = turf.buffer(
|
||||
maybeBufferedFeature,
|
||||
nogoBuffer,
|
||||
{ units: 'meters' }
|
||||
);
|
||||
maybeBufferedFeature = turf.buffer(maybeBufferedFeature, nogoBuffer, { units: 'meters' });
|
||||
}
|
||||
cleanedGeoJSONFeatures.push(maybeBufferedFeature);
|
||||
}
|
||||
});
|
||||
|
||||
if (cleanedGeoJSONFeatures.length === 0) {
|
||||
self.displayUploadError(
|
||||
'No valid area found in provided input.'
|
||||
);
|
||||
self.displayUploadError('No valid area found in provided input.');
|
||||
return false;
|
||||
}
|
||||
|
||||
var geoJSON = L.geoJson(
|
||||
turf.featureCollection(cleanedGeoJSONFeatures),
|
||||
{
|
||||
onEachFeature: function(feature, layer) {
|
||||
layer.options.nogoWeight =
|
||||
feature.properties.nogoWeight || nogoWeight;
|
||||
}
|
||||
var geoJSON = L.geoJson(turf.featureCollection(cleanedGeoJSONFeatures), {
|
||||
onEachFeature: function(feature, layer) {
|
||||
layer.options.nogoWeight = feature.properties.nogoWeight || nogoWeight;
|
||||
}
|
||||
);
|
||||
});
|
||||
var nogosPoints = geoJSON.getLayers().filter(function(e) {
|
||||
return e.feature.geometry.type === 'Point';
|
||||
});
|
||||
|
|
@ -332,9 +320,7 @@ BR.NogoAreas = L.Control.extend({
|
|||
BR.NogoAreas.include(L.Evented.prototype);
|
||||
|
||||
L.Editable.prototype.createVertexIcon = function(options) {
|
||||
return BR.Browser.touch
|
||||
? new L.Editable.TouchVertexIcon(options)
|
||||
: new L.Editable.VertexIcon(options);
|
||||
return BR.Browser.touch ? new L.Editable.TouchVertexIcon(options) : new L.Editable.VertexIcon(options);
|
||||
};
|
||||
|
||||
BR.EditingTooltip = L.Handler.extend({
|
||||
|
|
@ -351,12 +337,7 @@ BR.EditingTooltip = L.Handler.extend({
|
|||
addHooks: function() {
|
||||
// hack: listen to EasyButton click (instead of editable:drawing:start),
|
||||
// to get mouse position from event for initial tooltip location
|
||||
L.DomEvent.addListener(
|
||||
this.button.button,
|
||||
'click',
|
||||
this._addCreate,
|
||||
this
|
||||
);
|
||||
L.DomEvent.addListener(this.button.button, 'click', this._addCreate, this);
|
||||
|
||||
this.editTools.featuresLayer.on('layeradd', this._bind, this);
|
||||
|
||||
|
|
@ -366,12 +347,7 @@ BR.EditingTooltip = L.Handler.extend({
|
|||
},
|
||||
|
||||
removeHooks: function() {
|
||||
L.DomEvent.removeListener(
|
||||
this.button.button,
|
||||
'click',
|
||||
this._addCreate,
|
||||
this
|
||||
);
|
||||
L.DomEvent.removeListener(this.button.button, 'click', this._addCreate, this);
|
||||
|
||||
this.editTools.featuresLayer.off('layeradd', this._bind, this);
|
||||
|
||||
|
|
@ -396,9 +372,7 @@ BR.EditingTooltip = L.Handler.extend({
|
|||
if (!latlng && layer instanceof L.Layer) {
|
||||
latlng = L.latLng(
|
||||
layer.getBounds().getSouth(),
|
||||
0.5 *
|
||||
(layer.getBounds().getWest() +
|
||||
layer.getBounds().getEast())
|
||||
0.5 * (layer.getBounds().getWest() + layer.getBounds().getEast())
|
||||
);
|
||||
}
|
||||
L.Layer.prototype.openTooltip.call(this, layer, latlng);
|
||||
|
|
@ -444,11 +418,7 @@ BR.EditingTooltip = L.Handler.extend({
|
|||
var closeTooltip = function() {
|
||||
this.map.closeTooltip(tooltip);
|
||||
};
|
||||
this.editTools.once(
|
||||
'editable:editing editable:drawing:cancel',
|
||||
closeTooltip,
|
||||
this
|
||||
);
|
||||
this.editTools.once('editable:editing editable:drawing:cancel', closeTooltip, this);
|
||||
|
||||
if (BR.Browser.touch) {
|
||||
// can't move with cursor on touch devices, so show at start pos for a few seconds
|
||||
|
|
@ -501,9 +471,7 @@ BR.EditingTooltip = L.Handler.extend({
|
|||
BR.DeletableCircleEditor = L.Editable.CircleEditor.extend({
|
||||
_computeDeleteLatLng: function() {
|
||||
// While circle is not added to the map, _radius is not set.
|
||||
var delta =
|
||||
(this.feature._radius || this.feature._mRadius) *
|
||||
Math.cos(Math.PI / 4),
|
||||
var delta = (this.feature._radius || this.feature._mRadius) * Math.cos(Math.PI / 4),
|
||||
point = this.map.project(this.feature._latlng);
|
||||
return this.map.unproject([point.x - delta, point.y - delta]);
|
||||
},
|
||||
|
|
@ -530,12 +498,7 @@ BR.DeletableCircleEditor = L.Editable.CircleEditor.extend({
|
|||
},
|
||||
|
||||
initialize: function(map, feature, options) {
|
||||
L.Editable.CircleEditor.prototype.initialize.call(
|
||||
this,
|
||||
map,
|
||||
feature,
|
||||
options
|
||||
);
|
||||
L.Editable.CircleEditor.prototype.initialize.call(this, map, feature, options);
|
||||
this._deleteLatLng = this._computeDeleteLatLng();
|
||||
|
||||
// FeatureGroup instead of LayerGroup to propagate events to members
|
||||
|
|
@ -584,9 +547,7 @@ BR.DeleteMarker = L.Marker.extend({
|
|||
options: {
|
||||
draggable: false,
|
||||
icon: L.divIcon({
|
||||
iconSize: BR.Browser.touch
|
||||
? new L.Point(24, 24)
|
||||
: new L.Point(16, 16),
|
||||
iconSize: BR.Browser.touch ? new L.Point(24, 24) : new L.Point(16, 16),
|
||||
className: 'leaflet-div-icon fa fa-trash-o nogo-delete-marker'
|
||||
})
|
||||
},
|
||||
|
|
|
|||
|
|
@ -94,11 +94,7 @@ BR.Routing = L.Routing.extend({
|
|||
|
||||
// intercept listener: only re-show draw trailer after marker hover
|
||||
// when edit is not active (i.e. wasn't also supended)
|
||||
this._parent.off(
|
||||
'waypoint:mouseout',
|
||||
this._catchWaypointEvent,
|
||||
this
|
||||
);
|
||||
this._parent.off('waypoint:mouseout', this._catchWaypointEvent, this);
|
||||
this.on(
|
||||
'waypoint:mouseout',
|
||||
function(e) {
|
||||
|
|
@ -134,12 +130,7 @@ BR.Routing = L.Routing.extend({
|
|||
this._map.off('mouseout', hide, this);
|
||||
this._map.off('mouseover', show, this);
|
||||
L.DomEvent.off(this._map._controlContainer, 'mouseout', show, this);
|
||||
L.DomEvent.off(
|
||||
this._map._controlContainer,
|
||||
'mouseover',
|
||||
hide,
|
||||
this
|
||||
);
|
||||
L.DomEvent.off(this._map._controlContainer, 'mouseover', hide, this);
|
||||
});
|
||||
|
||||
// Call show after deleting last waypoint, but hide trailer.
|
||||
|
|
@ -159,11 +150,7 @@ BR.Routing = L.Routing.extend({
|
|||
);
|
||||
|
||||
// keys not working when map container does not have focus, use document instead
|
||||
L.DomEvent.removeListener(
|
||||
this._container,
|
||||
'keyup',
|
||||
this._keyupListener
|
||||
);
|
||||
L.DomEvent.removeListener(this._container, 'keyup', this._keyupListener);
|
||||
L.DomEvent.addListener(document, 'keyup', this._keyupListener, this);
|
||||
|
||||
// enable drawing mode
|
||||
|
|
@ -173,10 +160,7 @@ BR.Routing = L.Routing.extend({
|
|||
},
|
||||
|
||||
_addSegmentCasing: function(e) {
|
||||
var casing = L.polyline(
|
||||
e.layer.getLatLngs(),
|
||||
this.options.styles.trackCasing
|
||||
);
|
||||
var casing = L.polyline(e.layer.getLatLngs(), this.options.styles.trackCasing);
|
||||
this._segmentsCasing.addLayer(casing);
|
||||
e.layer._casing = casing;
|
||||
this._segments.bringToFront();
|
||||
|
|
@ -335,10 +319,7 @@ BR.Routing = L.Routing.extend({
|
|||
|
||||
_keyupListener: function(e) {
|
||||
// Suppress shortcut handling when a text input field is focussed
|
||||
if (
|
||||
document.activeElement.type == 'text' ||
|
||||
document.activeElement.type == 'textarea'
|
||||
) {
|
||||
if (document.activeElement.type == 'text' || document.activeElement.type == 'textarea') {
|
||||
return;
|
||||
}
|
||||
// add 'esc' to disable drawing
|
||||
|
|
|
|||
|
|
@ -36,11 +36,7 @@ BR.Sidebar = L.Control.Sidebar.extend({
|
|||
|
||||
this._rememberTabState();
|
||||
|
||||
if (
|
||||
L.Browser.touch &&
|
||||
BR.Browser.touchScreenDetectable &&
|
||||
!BR.Browser.touchScreen
|
||||
) {
|
||||
if (L.Browser.touch && BR.Browser.touchScreenDetectable && !BR.Browser.touchScreen) {
|
||||
L.DomUtil.removeClass(this._container, 'leaflet-touch');
|
||||
L.DomUtil.removeClass(this._tabContainer, 'leaflet-touch');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
(function(window) {
|
||||
var HAS_HASHCHANGE = (function() {
|
||||
var doc_mode = window.documentMode;
|
||||
return (
|
||||
'onhashchange' in window && (doc_mode === undefined || doc_mode > 7)
|
||||
);
|
||||
return 'onhashchange' in window && (doc_mode === undefined || doc_mode > 7);
|
||||
})();
|
||||
|
||||
L.Hash = function(map, options) {
|
||||
|
|
@ -47,12 +45,7 @@
|
|||
precision = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2)),
|
||||
layers = this.formatLayers();
|
||||
|
||||
var params = [
|
||||
zoom,
|
||||
center.lat.toFixed(precision),
|
||||
center.lng.toFixed(precision),
|
||||
layers
|
||||
];
|
||||
var params = [zoom, center.lat.toFixed(precision), center.lng.toFixed(precision), layers];
|
||||
url = '#map=' + params.join('/');
|
||||
if (this.additionalCb != null) {
|
||||
var additional = this.additionalCb();
|
||||
|
|
@ -92,9 +85,7 @@
|
|||
var layerString = decodeURIComponent(layerEncoded);
|
||||
|
||||
if (layerString) {
|
||||
obj = this.options.layersControl.getLayerFromString(
|
||||
layerString
|
||||
);
|
||||
obj = this.options.layersControl.getLayerFromString(layerString);
|
||||
}
|
||||
|
||||
return obj;
|
||||
|
|
@ -112,10 +103,7 @@
|
|||
return count;
|
||||
};
|
||||
|
||||
var layers = this._parseLayers(
|
||||
layersParam,
|
||||
this.options.layerSeparator
|
||||
);
|
||||
var layers = this._parseLayers(layersParam, this.options.layerSeparator);
|
||||
var found = layers.reduce(countFoundLayers, 0);
|
||||
|
||||
if (found < layers.length) {
|
||||
|
|
@ -158,9 +146,7 @@
|
|||
var objList = this.options.layersControl.getActiveLayers();
|
||||
var layerList = objList.map(
|
||||
L.bind(function(obj) {
|
||||
return encodeURIComponent(
|
||||
this.options.layersControl.toLayerString(obj)
|
||||
);
|
||||
return encodeURIComponent(this.options.layersControl.toLayerString(obj));
|
||||
}, this)
|
||||
);
|
||||
|
||||
|
|
@ -246,41 +232,22 @@
|
|||
isListening: false,
|
||||
hashChangeInterval: null,
|
||||
startListening: function() {
|
||||
this.map.on(
|
||||
'moveend layeradd layerremove',
|
||||
this.onMapMove,
|
||||
this
|
||||
);
|
||||
this.map.on('moveend layeradd layerremove', this.onMapMove, this);
|
||||
|
||||
if (HAS_HASHCHANGE) {
|
||||
L.DomEvent.addListener(
|
||||
window,
|
||||
'hashchange',
|
||||
this.onHashChange
|
||||
);
|
||||
L.DomEvent.addListener(window, 'hashchange', this.onHashChange);
|
||||
} else {
|
||||
clearInterval(this.hashChangeInterval);
|
||||
this.hashChangeInterval = setInterval(
|
||||
this.onHashChange,
|
||||
50
|
||||
);
|
||||
this.hashChangeInterval = setInterval(this.onHashChange, 50);
|
||||
}
|
||||
this.isListening = true;
|
||||
},
|
||||
|
||||
stopListening: function() {
|
||||
this.map.off(
|
||||
'moveend layeradd layerremove',
|
||||
this.onMapMove,
|
||||
this
|
||||
);
|
||||
this.map.off('moveend layeradd layerremove', this.onMapMove, this);
|
||||
|
||||
if (HAS_HASHCHANGE) {
|
||||
L.DomEvent.removeListener(
|
||||
window,
|
||||
'hashchange',
|
||||
this.onHashChange
|
||||
);
|
||||
L.DomEvent.removeListener(window, 'hashchange', this.onHashChange);
|
||||
} else {
|
||||
clearInterval(this.hashChangeInterval);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,10 +7,7 @@ BR.stravaSegments = function(map, layersControl) {
|
|||
stravaToken: BR.keys.strava
|
||||
})
|
||||
.addTo(map);
|
||||
layersControl.addOverlay(
|
||||
stravaControl.stravaLayer,
|
||||
i18next.t('map.layer.strava-segments')
|
||||
);
|
||||
layersControl.addOverlay(stravaControl.stravaLayer, i18next.t('map.layer.strava-segments'));
|
||||
stravaControl.onError = function(err) {
|
||||
BR.message.showError(
|
||||
i18next.t('warning.strava-error', {
|
||||
|
|
|
|||
|
|
@ -40,30 +40,16 @@ L.BRouter = L.Class.extend({
|
|||
|
||||
getUrlParams: function(latLngs, format) {
|
||||
params = {};
|
||||
if (this._getLonLatsString(latLngs) != null)
|
||||
params.lonlats = this._getLonLatsString(latLngs);
|
||||
if (this._getLonLatsString(latLngs) != null) params.lonlats = this._getLonLatsString(latLngs);
|
||||
|
||||
if (
|
||||
this.options.nogos &&
|
||||
this._getNogosString(this.options.nogos).length > 0
|
||||
)
|
||||
if (this.options.nogos && this._getNogosString(this.options.nogos).length > 0)
|
||||
params.nogos = this._getNogosString(this.options.nogos);
|
||||
|
||||
if (
|
||||
this.options.polylines &&
|
||||
this._getNogosPolylinesString(this.options.polylines).length > 0
|
||||
)
|
||||
params.polylines = this._getNogosPolylinesString(
|
||||
this.options.polylines
|
||||
);
|
||||
if (this.options.polylines && this._getNogosPolylinesString(this.options.polylines).length > 0)
|
||||
params.polylines = this._getNogosPolylinesString(this.options.polylines);
|
||||
|
||||
if (
|
||||
this.options.polygons &&
|
||||
this._getNogosPolygonsString(this.options.polygons).length > 0
|
||||
)
|
||||
params.polygons = this._getNogosPolygonsString(
|
||||
this.options.polygons
|
||||
);
|
||||
if (this.options.polygons && this._getNogosPolygonsString(this.options.polygons).length > 0)
|
||||
params.polygons = this._getNogosPolygonsString(this.options.polygons);
|
||||
|
||||
if (this.options.profile != null) params.profile = this.options.profile;
|
||||
|
||||
|
|
@ -77,10 +63,7 @@ L.BRouter = L.Class.extend({
|
|||
if (params.alternativeidx == 0) delete params.alternativeidx;
|
||||
|
||||
// don't add custom profile, as these are only stored temporarily
|
||||
if (
|
||||
params.profile &&
|
||||
params.profile.substring(0, 7) === 'custom_'
|
||||
) {
|
||||
if (params.profile && params.profile.substring(0, 7) === 'custom_') {
|
||||
delete params.profile;
|
||||
}
|
||||
}
|
||||
|
|
@ -117,20 +100,12 @@ L.BRouter = L.Class.extend({
|
|||
var args = [];
|
||||
if (urlParams.lonlats != null && urlParams.lonlats.length > 0)
|
||||
args.push(L.Util.template('lonlats={lonlats}', urlParams));
|
||||
if (urlParams.nogos != null)
|
||||
args.push(L.Util.template('nogos={nogos}', urlParams));
|
||||
if (urlParams.polylines != null)
|
||||
args.push(L.Util.template('polylines={polylines}', urlParams));
|
||||
if (urlParams.polygons != null)
|
||||
args.push(L.Util.template('polygons={polygons}', urlParams));
|
||||
if (urlParams.profile != null)
|
||||
args.push(L.Util.template('profile={profile}', urlParams));
|
||||
if (urlParams.alternativeidx != null)
|
||||
args.push(
|
||||
L.Util.template('alternativeidx={alternativeidx}', urlParams)
|
||||
);
|
||||
if (urlParams.format != null)
|
||||
args.push(L.Util.template('format={format}', urlParams));
|
||||
if (urlParams.nogos != null) args.push(L.Util.template('nogos={nogos}', urlParams));
|
||||
if (urlParams.polylines != null) args.push(L.Util.template('polylines={polylines}', urlParams));
|
||||
if (urlParams.polygons != null) args.push(L.Util.template('polygons={polygons}', urlParams));
|
||||
if (urlParams.profile != null) args.push(L.Util.template('profile={profile}', urlParams));
|
||||
if (urlParams.alternativeidx != null) args.push(L.Util.template('alternativeidx={alternativeidx}', urlParams));
|
||||
if (urlParams.format != null) args.push(L.Util.template('format={format}', urlParams));
|
||||
if (trackname)
|
||||
args.push(
|
||||
L.Util.template('trackname={trackname}', {
|
||||
|
|
@ -141,9 +116,7 @@ L.BRouter = L.Class.extend({
|
|||
|
||||
var prepend_host = format != null;
|
||||
|
||||
return (
|
||||
(prepend_host ? BR.conf.host : '') + '/brouter?' + args.join('&')
|
||||
);
|
||||
return (prepend_host ? BR.conf.host : '') + '/brouter?' + args.join('&');
|
||||
},
|
||||
|
||||
getRoute: function(latLngs, cb) {
|
||||
|
|
@ -174,8 +147,7 @@ L.BRouter = L.Class.extend({
|
|||
xhr.status === 200 &&
|
||||
xhr.responseText &&
|
||||
// application error when not GeoJSON format (text/plain for errors)
|
||||
xhr.getResponseHeader('Content-Type').split(';')[0] ===
|
||||
'application/vnd.geo+json'
|
||||
xhr.getResponseHeader('Content-Type').split(';')[0] === 'application/vnd.geo+json'
|
||||
) {
|
||||
// leaflet.spin
|
||||
//gpxLayer.fire('data:loaded');
|
||||
|
|
@ -221,11 +193,7 @@ L.BRouter = L.Class.extend({
|
|||
_handleProfileResponse: function(xhr, cb) {
|
||||
var response;
|
||||
|
||||
if (
|
||||
xhr.status === 200 &&
|
||||
xhr.responseText &&
|
||||
xhr.responseText.length > 0
|
||||
) {
|
||||
if (xhr.status === 200 && xhr.responseText && xhr.responseText.length > 0) {
|
||||
response = JSON.parse(xhr.responseText);
|
||||
cb(response.error, response.profileid);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ var brouterCgi = (function() {
|
|||
// http://brouter.de/cgi-bin/brouter.sh?coords=13.404681_52.520185_13.340278_52.512356_trekking_0
|
||||
//var URL_TEMPLATE = '/cgi-bin/proxy.cgi?url=' + 'http://brouter.de/cgi-bin/brouter.sh?coords={fromLng}_{fromLat}_{toLng}_{toLat}_{profile}_{alt}';
|
||||
var URL_TEMPLATE =
|
||||
'/proxy.php?url=' +
|
||||
'cgi-bin/brouter.sh?coords={fromLng}_{fromLat}_{toLng}_{toLat}_{profile}_{alt}';
|
||||
'/proxy.php?url=' + 'cgi-bin/brouter.sh?coords={fromLng}_{fromLat}_{toLng}_{toLat}_{profile}_{alt}';
|
||||
var PRECISION = 6;
|
||||
|
||||
function getUrl(polyline) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue