refact: use shorthand method and property syntax
This commit is contained in:
parent
babd154596
commit
76f31aeb2b
44 changed files with 520 additions and 514 deletions
|
|
@ -6,7 +6,7 @@ BR.RoutingPathQuality = L.Control.extend({
|
|||
},
|
||||
},
|
||||
|
||||
initialize: function (map, layersControl, options) {
|
||||
initialize(map, layersControl, options) {
|
||||
L.setOptions(this, options);
|
||||
|
||||
// hotline uses canvas and cannot be moved in front of the svg, so we create another pane
|
||||
|
|
@ -35,9 +35,9 @@ BR.RoutingPathQuality = L.Control.extend({
|
|||
1.0: '#ff0000', // red
|
||||
},
|
||||
outlineColor: 'dimgray',
|
||||
renderer: renderer,
|
||||
renderer,
|
||||
},
|
||||
valueFunction: function (latLng, prevLatLng) {
|
||||
valueFunction(latLng, prevLatLng) {
|
||||
var deltaAltitude = latLng.alt - prevLatLng.alt, // in m
|
||||
distance = prevLatLng.distanceTo(latLng); // in m
|
||||
if (distance === 0) {
|
||||
|
|
@ -53,9 +53,9 @@ BR.RoutingPathQuality = L.Control.extend({
|
|||
provider: new HotLineQualityProvider({
|
||||
hotlineOptions: {
|
||||
outlineColor: 'dimgray',
|
||||
renderer: renderer,
|
||||
renderer,
|
||||
},
|
||||
valueFunction: function (latLng) {
|
||||
valueFunction(latLng) {
|
||||
return latLng.alt;
|
||||
},
|
||||
}),
|
||||
|
|
@ -65,7 +65,7 @@ BR.RoutingPathQuality = L.Control.extend({
|
|||
icon: 'fa-road',
|
||||
provider: new HotLineQualityProvider({
|
||||
hotlineOptions: {
|
||||
renderer: renderer,
|
||||
renderer,
|
||||
palette: {
|
||||
// normal range
|
||||
0.0: 'red',
|
||||
|
|
@ -229,9 +229,9 @@ BR.RoutingPathQuality = L.Control.extend({
|
|||
// disables line simplification, so short segments won't disappear on some zoom levels
|
||||
smoothFactor: 0,
|
||||
outlineColor: 'dimgray',
|
||||
renderer: renderer,
|
||||
renderer,
|
||||
},
|
||||
valueFunction: function (latLng) {
|
||||
valueFunction(latLng) {
|
||||
var feature = latLng.feature;
|
||||
var cost = feature.cost.perKm;
|
||||
var distance = feature.distance / 1000; // in km
|
||||
|
|
@ -252,7 +252,7 @@ BR.RoutingPathQuality = L.Control.extend({
|
|||
this._muted = false;
|
||||
},
|
||||
|
||||
onAdd: function (map) {
|
||||
onAdd(map) {
|
||||
this._map = map;
|
||||
|
||||
map.on(
|
||||
|
|
@ -311,28 +311,28 @@ BR.RoutingPathQuality = L.Control.extend({
|
|||
}
|
||||
|
||||
this.routingPathButton = new L.easyButton({
|
||||
states: states,
|
||||
states,
|
||||
}).addTo(map);
|
||||
return new L.DomUtil.create('div');
|
||||
},
|
||||
|
||||
_activate: function (btn) {
|
||||
_activate(btn) {
|
||||
this._active = true;
|
||||
this._getIcon(btn).classList.add('active');
|
||||
this._routingSegments.addTo(this._map);
|
||||
},
|
||||
|
||||
_deactivate: function (btn) {
|
||||
_deactivate(btn) {
|
||||
this._active = false;
|
||||
this._getIcon(btn).classList.remove('active');
|
||||
this._map.removeLayer(this._routingSegments);
|
||||
},
|
||||
|
||||
_getIcon: function (btn) {
|
||||
_getIcon(btn) {
|
||||
return btn.button.firstChild.firstChild;
|
||||
},
|
||||
|
||||
update: function (track, layer) {
|
||||
update(track, layer) {
|
||||
var segments = [];
|
||||
layer.eachLayer(function (layer) {
|
||||
segments.push(layer);
|
||||
|
|
@ -341,12 +341,12 @@ BR.RoutingPathQuality = L.Control.extend({
|
|||
this._update(this.segments);
|
||||
},
|
||||
|
||||
setProvider: function (provider) {
|
||||
setProvider(provider) {
|
||||
this.selectedProvider = provider;
|
||||
this._update(this.segments);
|
||||
},
|
||||
|
||||
_update: function (segments) {
|
||||
_update(segments) {
|
||||
this._routingSegments.clearLayers();
|
||||
var layers = this.providers[this.selectedProvider].provider.computeLayers(segments);
|
||||
if (layers) {
|
||||
|
|
@ -356,7 +356,7 @@ BR.RoutingPathQuality = L.Control.extend({
|
|||
}
|
||||
},
|
||||
|
||||
_keydownListener: function (e) {
|
||||
_keydownListener(e) {
|
||||
if (!BR.Util.keyboardShortcutsAllowed(e)) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -369,7 +369,7 @@ BR.RoutingPathQuality = L.Control.extend({
|
|||
}
|
||||
},
|
||||
|
||||
_keyupListener: function (e) {
|
||||
_keyupListener(e) {
|
||||
if (BR.Util.keyboardShortcutsAllowed(e) && this._muted && e.keyCode === this.options.shortcut.muteKeyCode) {
|
||||
this._muted = false;
|
||||
this._activate(this.routingPathButton);
|
||||
|
|
@ -378,12 +378,12 @@ BR.RoutingPathQuality = L.Control.extend({
|
|||
});
|
||||
|
||||
var HotLineQualityProvider = L.Class.extend({
|
||||
initialize: function (options) {
|
||||
initialize(options) {
|
||||
this.hotlineOptions = options.hotlineOptions;
|
||||
this.valueFunction = options.valueFunction;
|
||||
},
|
||||
|
||||
computeLayers: function (segments) {
|
||||
computeLayers(segments) {
|
||||
var layers = [];
|
||||
if (segments) {
|
||||
var segmentLatLngs = [];
|
||||
|
|
@ -415,7 +415,7 @@ var HotLineQualityProvider = L.Class.extend({
|
|||
return layers;
|
||||
},
|
||||
|
||||
_computeLatLngVals: function (segment) {
|
||||
_computeLatLngVals(segment) {
|
||||
var latLngVals = [],
|
||||
segmentLatLngs = segment.getLatLngs(),
|
||||
segmentLength = segmentLatLngs.length;
|
||||
|
|
@ -433,11 +433,11 @@ var HotLineQualityProvider = L.Class.extend({
|
|||
return latLngVals;
|
||||
},
|
||||
|
||||
_convertToArray: function (latLng, val) {
|
||||
_convertToArray(latLng, val) {
|
||||
return [latLng.lat, latLng.lng, val];
|
||||
},
|
||||
|
||||
_calcMinMaxValues: function (lines, pct) {
|
||||
_calcMinMaxValues(lines, pct) {
|
||||
lines.sort(function (a, b) {
|
||||
return a[2] - b[2];
|
||||
});
|
||||
|
|
@ -447,8 +447,8 @@ var HotLineQualityProvider = L.Class.extend({
|
|||
max = min + 1;
|
||||
}
|
||||
return {
|
||||
min: min,
|
||||
max: max,
|
||||
min,
|
||||
max,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue