Toggle drawing mode via panel button (#41)
This commit is contained in:
parent
4d76d87709
commit
fcfc1d5cfe
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
|
||||
|
||||
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',
|
||||
function () {
|
||||
bootbox.confirm({
|
||||
|
|
@ -179,7 +199,9 @@
|
|||
});
|
||||
},
|
||||
'Clear route'
|
||||
).addTo(map);
|
||||
);
|
||||
|
||||
drawToolbar = L.easyBar([drawButton, deleteButton]).addTo(map);
|
||||
|
||||
function updateRoute(evt) {
|
||||
router.setOptions(evt.options);
|
||||
|
|
@ -276,10 +298,17 @@
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
routing.on('routing:routeWaypointEnd routing:setWaypointsEnd', function(evt) {
|
||||
search.clear();
|
||||
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) {
|
||||
if (err) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue