Skip to content

Commit

Permalink
Merge pull request #324 from opoto/master
Browse files Browse the repository at this point in the history
Fixes #304
  • Loading branch information
perliedman authored Oct 8, 2016
2 parents bdf2c39 + 06d0264 commit 7211c1b
Showing 1 changed file with 28 additions and 25 deletions.
53 changes: 28 additions & 25 deletions src/L.Routing.Control.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,37 +48,39 @@
}
},

onZoomEnd: function() {
if (!this._selectedRoute ||
!this._router.requiresMoreDetail) {
return;
}

var map = this._map;
if (this._router.requiresMoreDetail(this._selectedRoute,
map.getZoom(), map.getBounds())) {
this.route({
callback: L.bind(function(err, routes) {
var i;
if (!err) {
for (i = 0; i < routes.length; i++) {
this._routes[i].properties = routes[i].properties;
}
this._updateLineCallback(err, routes);
}

}, this),
simplifyGeometry: false,
geometryOnly: true
});
}
},

onAdd: function(map) {
var container = L.Routing.Itinerary.prototype.onAdd.call(this, map);

this._map = map;
this._map.addLayer(this._plan);

this._map.on('zoomend', function() {
if (!this._selectedRoute ||
!this._router.requiresMoreDetail) {
return;
}

var map = this._map;
if (this._router.requiresMoreDetail(this._selectedRoute,
map.getZoom(), map.getBounds())) {
this.route({
callback: L.bind(function(err, routes) {
var i;
if (!err) {
for (i = 0; i < routes.length; i++) {
this._routes[i].properties = routes[i].properties;
}
this._updateLineCallback(err, routes);
}

}, this),
simplifyGeometry: false,
geometryOnly: true
});
}
}, this);
this._map.on('zoomend', this.onZoomEnd, this);

if (this._plan.options.geocoder) {
container.insertBefore(this._plan.createGeocoders(), container.firstChild);
Expand All @@ -88,6 +90,7 @@
},

onRemove: function(map) {
map.off('zoomend', this.onZoomEnd, this);
if (this._line) {
map.removeLayer(this._line);
}
Expand Down

0 comments on commit 7211c1b

Please sign in to comment.