commit 4fa30140abcb5b4ce748a341ff6c4d0042369523
parent 3d24ec0eef4e3c022bfc39c910b46dd5b733474b
Author: Sergej Orlov <wladimirych@gmail.com>
Date: Sat, 18 Feb 2017 22:28:36 +0300
[elevation profile] better server errors handling
Diffstat:
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/lib/leaflet.control.elevation-profile/index.js b/src/lib/leaflet.control.elevation-profile/index.js
@@ -200,7 +200,7 @@ L.Control.ElevationProfile = L.Class.extend({
samplingInterval: 50
},
- initialize: function(latlngs, options) {
+ initialize: function(map, latlngs, options) {
L.setOptions(this, options);
this.path = latlngs;
var samples = this.samples = pathRegularSamples(this.path, this.options.samplingInterval);
@@ -211,7 +211,7 @@ L.Control.ElevationProfile = L.Class.extend({
this._getElevation(samples)
.then(function(values) {
self.values = values;
- self.updateGraph();
+ self._addTo(map);
}
)
.catch((e) => {
@@ -221,7 +221,7 @@ L.Control.ElevationProfile = L.Class.extend({
},
- addTo: function(map) {
+ _addTo: function(map) {
this._map = map;
var container = this._container = L.DomUtil.create('div', 'elevation-profile-container');
L.Control.prototype._stopContainerEvents.call(this);
diff --git a/src/lib/leaflet.control.track-list/track-list.js b/src/lib/leaflet.control.track-list/track-list.js
@@ -999,10 +999,10 @@ L.Control.TrackList = L.Control.extend({
this._elevationControl.removeFrom(this._map);
}
this.stopEditLine();
- this._elevationControl = new L.Control.ElevationProfile(line.getLatLngs(), {
+ this._elevationControl = new L.Control.ElevationProfile(this._map, line.getLatLngs(), {
samplingInterval: this.calcSamplingInterval(line.getLength())
}
- ).addTo(this._map);
+ );
},
showElevationProfileForTrack: function(track) {
@@ -1021,7 +1021,7 @@ L.Control.TrackList = L.Control.extend({
this._elevationControl = new L.Control.ElevationProfile(this._map, path, {
samplingInterval: this.calcSamplingInterval(new L.MeasuredLine(path).getLength())
}
- ).addTo(this._map);
+ );
}