animated dashed line as loading indicator, instead of a spinner, resolves #3

This commit is contained in:
Norbert Renner 2014-08-15 11:31:05 +02:00
parent 61238193cf
commit f0d0182256
2 changed files with 43 additions and 1 deletions

View file

@ -70,11 +70,29 @@ BR.Routing = L.Routing.extend({
}
,_routeSegment: function(m1, m2, cb) {
var loadingTrailer;
// change segment color before request to indicate recalculation (mark old)
if (m1 && m1._routing.nextLine !== null) {
m1._routing.nextLine.options.color = 'dimgray';
m1._routing.nextLine._updateStyle();
}
L.Routing.prototype._routeSegment.call(this, m1, m2, cb);
// animate dashed trailer as loading indicator
if (m1 && m2) {
loadingTrailer = new L.Polyline([m1.getLatLng(), m2.getLatLng()], {
opacity: 0.6,
dashArray: [10, 10],
className: 'loading-trailer'
});
loadingTrailer.addTo(this._map);
}
L.Routing.prototype._routeSegment.call(this, m1, m2, L.bind(function(err, data) {
if (loadingTrailer) {
this._map.removeLayer(loadingTrailer);
}
cb(err, data);
}, this));
}
});