Merge pull request #226 from bagage/222-add-users-poi

export user's POI (point of interest)
This commit is contained in:
Norbert Renner 2019-10-10 22:17:44 +02:00 committed by GitHub
commit ddf8e27085
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 260 additions and 35 deletions

View file

@ -32,9 +32,8 @@
sidebar,
drawButton,
deleteRouteButton,
drawToolbar,
pois,
urlHash,
reverseRoute,
saveWarningShown = false;
// By default bootstrap-select use glyphicons
@ -73,7 +72,7 @@
]
});
reverseRouteButton = L.easyButton(
var reverseRouteButton = L.easyButton(
'fa-random',
function() {
routing.reverse();
@ -81,7 +80,7 @@
i18next.t('map.reverse-route')
);
deletePointButton = L.easyButton(
var deletePointButton = L.easyButton(
'<span><i class="fa fa-caret-left"></i><i class="fa fa-map-marker" style="margin-left: 1px; color: gray;"></i></span>',
function() {
routing.removeWaypoint(routing.getLast(), function(err, data) {});
@ -94,7 +93,7 @@
function() {
bootbox.prompt({
size: 'small',
title: i18next.t('map.delete-route-nogos'),
title: i18next.t('map.clear-route'),
inputType: 'checkbox',
inputOptions: [
{
@ -104,6 +103,10 @@
{
text: i18next.t('map.delete-nogo-areas'),
value: 'nogo'
},
{
text: i18next.t('map.delete-pois'),
value: 'pois'
}
],
value: ['route'],
@ -115,13 +118,16 @@
if (result.indexOf('nogo') !== -1) {
nogos.clear();
}
if (result.indexOf('pois') !== -1) {
pois.clear();
}
onUpdate();
urlHash.onMapMove();
}
}
});
},
i18next.t('map.delete-route-nogos')
i18next.t('map.clear-route')
);
function updateRoute(evt) {
@ -161,7 +167,6 @@
} else {
stats = new BR.TrackStats();
}
exportRoute = new BR.Export(router);
elevation = new BR.Elevation();
profile = new BR.Profile();
@ -208,6 +213,12 @@
styles: BR.conf.routingStyles
});
pois = new BR.PoiMarkers({
routing: routing
});
exportRoute = new BR.Export(router, pois);
routing.on('routing:routeWaypointEnd routing:setWaypointsEnd', function(evt) {
search.clear();
onUpdate(evt && evt.err);
@ -250,6 +261,8 @@
elevation.addBelow(map);
pois.addTo(map);
sidebar = BR.sidebar({
defaultTabId: BR.conf.transit ? 'tab_itinerary' : 'tab_profile',
listeningTabs: {
@ -262,13 +275,7 @@
}
nogos.addTo(map);
drawToolbar = L.easyBar([
drawButton,
reverseRouteButton,
nogos.getButton(),
deletePointButton,
deleteRouteButton
]).addTo(map);
L.easyBar([drawButton, reverseRouteButton, nogos.getButton(), deletePointButton, deleteRouteButton]).addTo(map);
nogos.preventRoutePointOnCreate(routing);
if (BR.keys.strava) {
@ -313,6 +320,7 @@
return p;
};
if (url == null) return;
var opts = router.parseUrlParams(url2params(url));
router.setOptions(opts);
routingOptions.setOptions(opts);
@ -324,6 +332,10 @@
routing.clear();
routing.setWaypoints(opts.lonlats);
}
if (opts.pois) {
pois.setMarkers(opts.pois);
}
};
var onInvalidHashChangeCb = function(params) {
@ -336,9 +348,13 @@
// do not initialize immediately
urlHash = new L.Hash(null, null);
// this callback is used to append anything in URL after L.Hash wrote #map=zoom/lat/lng/layer
urlHash.additionalCb = function() {
var url = router.getUrl(routing.getWaypoints(), null).substr('brouter?'.length + 1);
var url = router.getUrl(routing.getWaypoints(), pois.getMarkers(), null).substr('brouter?'.length + 1);
// by default brouter use | as separator. To make URL more human-readable, we remplace them with ; for users
url = url.replace(/\|/g, ';');
return url.length > 0 ? '&' + url : null;
};
urlHash.onHashChangeCb = onHashChangeCb;
@ -355,6 +371,7 @@
routingOptions.on('update', urlHash.onMapMove, urlHash);
nogos.on('update', urlHash.onMapMove, urlHash);
pois.on('update', urlHash.onMapMove, urlHash);
// waypoint add, move, delete (but last)
routing.on('routing:routeWaypointEnd', urlHash.onMapMove, urlHash);
// delete last waypoint
@ -403,6 +420,8 @@
});
}
L.AwesomeMarkers.Icon.prototype.options.prefix = 'fa';
i18next
.use(window.i18nextXHRBackend)
.use(window.i18nextBrowserLanguageDetector)