Merge pull request #50 from bagage/master
Toggle drawing mode via panel button (#41)
This commit is contained in:
commit
56445e8547
4 changed files with 35 additions and 6 deletions
2
dist/brouter-web.css
vendored
2
dist/brouter-web.css
vendored
File diff suppressed because one or more lines are too long
4
dist/brouter-web.js
vendored
4
dist/brouter-web.js
vendored
File diff suppressed because one or more lines are too long
2
dist/brouter-web.js.map
vendored
2
dist/brouter-web.js.map
vendored
File diff suppressed because one or more lines are too long
33
js/index.js
33
js/index.js
|
|
@ -163,7 +163,27 @@
|
||||||
|
|
||||||
router = L.bRouter(); //brouterCgi dummyRouter
|
router = L.bRouter(); //brouterCgi dummyRouter
|
||||||
|
|
||||||
routingToolbar = L.easyButton(
|
drawButton = L.easyButton({
|
||||||
|
states: [{
|
||||||
|
stateName: 'deactivate-draw',
|
||||||
|
icon: 'glyphicon-ok',
|
||||||
|
onClick: function (control) {
|
||||||
|
routing.draw(false);
|
||||||
|
control.state('activate-draw');
|
||||||
|
},
|
||||||
|
title: 'Stop drawing route'
|
||||||
|
}, {
|
||||||
|
stateName: 'activate-draw',
|
||||||
|
icon: 'glyphicon-road',
|
||||||
|
onClick: function (control) {
|
||||||
|
routing.draw(true);
|
||||||
|
control.state('deactivate-draw');
|
||||||
|
},
|
||||||
|
title: 'Draw route'
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
|
||||||
|
deleteButton = L.easyButton(
|
||||||
'glyphicon-trash',
|
'glyphicon-trash',
|
||||||
function () {
|
function () {
|
||||||
bootbox.confirm({
|
bootbox.confirm({
|
||||||
|
|
@ -179,7 +199,9 @@
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
'Clear route'
|
'Clear route'
|
||||||
).addTo(map);
|
);
|
||||||
|
|
||||||
|
drawToolbar = L.easyBar([drawButton, deleteButton]).addTo(map);
|
||||||
|
|
||||||
function updateRoute(evt) {
|
function updateRoute(evt) {
|
||||||
router.setOptions(evt.options);
|
router.setOptions(evt.options);
|
||||||
|
|
@ -276,10 +298,17 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
routing.on('routing:routeWaypointEnd routing:setWaypointsEnd', function(evt) {
|
routing.on('routing:routeWaypointEnd routing:setWaypointsEnd', function(evt) {
|
||||||
search.clear();
|
search.clear();
|
||||||
onUpdate(evt && evt.err);
|
onUpdate(evt && evt.err);
|
||||||
});
|
});
|
||||||
|
map.on('routing:draw-start', function() {
|
||||||
|
drawButton.state('deactivate-draw');
|
||||||
|
});
|
||||||
|
map.on('routing:draw-end', function() {
|
||||||
|
drawButton.state('activate-draw');
|
||||||
|
});
|
||||||
|
|
||||||
function onUpdate(err) {
|
function onUpdate(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue