show nearby locations
This commit is contained in:
parent
3134829cc7
commit
27b35a384d
7 changed files with 68 additions and 19 deletions
|
@ -213,13 +213,18 @@ c3nav = {
|
|||
},
|
||||
|
||||
state: {},
|
||||
update_state: function(routing, replace, details, options) {
|
||||
update_state: function(routing, replace, details, options, nearby) {
|
||||
if (typeof routing !== "boolean") routing = c3nav.state.routing;
|
||||
|
||||
if (details) {
|
||||
options = false;
|
||||
nearby = false;
|
||||
} else if (options) {
|
||||
details = false;
|
||||
nearby = false;
|
||||
} else if (nearby) {
|
||||
details = false;
|
||||
options = false;
|
||||
}
|
||||
|
||||
var destination = $('#destination-input').data('location'),
|
||||
|
@ -230,7 +235,8 @@ c3nav = {
|
|||
destination: destination,
|
||||
sidebar: true,
|
||||
details: !!details,
|
||||
options: !!options
|
||||
options: !!options,
|
||||
nearby: !!nearby,
|
||||
};
|
||||
|
||||
c3nav._push_state(new_state, replace);
|
||||
|
@ -669,6 +675,9 @@ c3nav = {
|
|||
if (state.details && (url.startsWith('/l/') || url.startsWith('/r/'))) {
|
||||
url += 'details/'
|
||||
}
|
||||
if (state.nearby && url.startsWith('/l/')) {
|
||||
url += 'nearby/'
|
||||
}
|
||||
if (state.options && url.startsWith('/r/')) {
|
||||
url += 'options/'
|
||||
}
|
||||
|
@ -1212,6 +1221,7 @@ c3nav = {
|
|||
L.Icon.Default.imagePath = '/static/leaflet/images/';
|
||||
c3nav._add_icon('origin');
|
||||
c3nav._add_icon('destination');
|
||||
c3nav._add_icon('nearby');
|
||||
|
||||
// setup scale control
|
||||
L.control.scale({imperial: false}).addTo(c3nav.map);
|
||||
|
@ -1281,7 +1291,7 @@ c3nav = {
|
|||
if (nearby) {
|
||||
var $destination = $('#destination-input');
|
||||
c3nav._locationinput_set($destination, data);
|
||||
c3nav.update_state(false);
|
||||
c3nav.update_state(false, false, false, false, true);
|
||||
} else {
|
||||
newpopup = L.popup(c3nav._add_map_padding({
|
||||
className: 'location-popup',
|
||||
|
@ -1333,6 +1343,24 @@ c3nav = {
|
|||
c3nav._visible_map_locations = [];
|
||||
if (origin) c3nav._merge_bounds(bounds, c3nav._add_location_to_map(origin, single ? new L.Icon.Default() : c3nav.originIcon));
|
||||
if (destination) c3nav._merge_bounds(bounds, c3nav._add_location_to_map(destination, single ? new L.Icon.Default() : c3nav.destinationIcon));
|
||||
var done = [];
|
||||
if (c3nav.state.nearby && destination && 'areas' in destination) {
|
||||
if (destination.space) {
|
||||
c3nav._merge_bounds(bounds, c3nav._add_location_to_map(c3nav.locations_by_id[destination.space], c3nav.nearbyIcon, true));
|
||||
}
|
||||
if (destination.near_area) {
|
||||
done.push(destination.near_area);
|
||||
c3nav._merge_bounds(bounds, c3nav._add_location_to_map(c3nav.locations_by_id[destination.near_area], c3nav.nearbyIcon, true));
|
||||
}
|
||||
for (var area of destination.areas) {
|
||||
done.push(area);
|
||||
c3nav._merge_bounds(bounds, c3nav._add_location_to_map(c3nav.locations_by_id[area], c3nav.nearbyIcon, true));
|
||||
}
|
||||
for (var location of destination.nearby) {
|
||||
if (location in done) continue;
|
||||
c3nav._merge_bounds(bounds, c3nav._add_location_to_map(c3nav.locations_by_id[location], c3nav.nearbyIcon, true));
|
||||
}
|
||||
}
|
||||
c3nav._locationLayerBounds = bounds;
|
||||
},
|
||||
fly_to_bounds: function(replace_state, nofly) {
|
||||
|
|
|
@ -8,12 +8,13 @@ slug = r'(?P<slug>[a-z0-9-_.:]+)'
|
|||
coordinates = r'(?P<coordinates>[a-z0-9-_:]+:-?\d+(\.\d+)?:-?\d+(\.\d+)?)'
|
||||
slug2 = r'(?P<slug2>[a-z0-9-_.:]+)'
|
||||
details = r'(?P<details>details/)?'
|
||||
nearby = r'(?P<nearby>nearby/)?'
|
||||
options = r'(?P<options>options/)?'
|
||||
pos = r'(@(?P<level>[a-z0-9-_:]+),(?P<x>-?\d+(\.\d+)?),(?P<y>-?\d+(\.\d+)?),(?P<zoom>-?\d+(\.\d+)?))?'
|
||||
embed = r'(?P<embed>embed/)?'
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^%s(?P<mode>[l])/%s/%s%s$' % (embed, slug, details, pos), map_index, name='site.index'),
|
||||
url(r'^%s(?P<mode>[l])/%s/(%s|%s)%s$' % (embed, slug, details, nearby, pos), map_index, name='site.index'),
|
||||
url(r'^%s(?P<mode>[od])/%s/%s$' % (embed, slug, pos), map_index, name='site.index'),
|
||||
url(r'^%sr/%s/%s/(%s|%s)%s$' % (embed, slug, slug2, details, options, pos), map_index, name='site.index'),
|
||||
url(r'^%s(?P<mode>r)/%s$' % (embed, pos), map_index, name='site.index'),
|
||||
|
|
|
@ -57,7 +57,7 @@ def check_location(location: Optional[str], request) -> Optional[SpecificLocatio
|
|||
return location
|
||||
|
||||
|
||||
def map_index(request, mode=None, slug=None, slug2=None, details=None, options=None,
|
||||
def map_index(request, mode=None, slug=None, slug2=None, details=None, options=None, nearby=None,
|
||||
level=None, x=None, y=None, zoom=None, embed=None):
|
||||
|
||||
# check for access token
|
||||
|
@ -108,6 +108,7 @@ def map_index(request, mode=None, slug=None, slug2=None, details=None, options=N
|
|||
'sidebar': routing or destination is not None,
|
||||
'details': True if details else False,
|
||||
'options': True if options else False,
|
||||
'nearby': True if nearby else False,
|
||||
}
|
||||
|
||||
levels = levels_by_short_label_for_request(request)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue