first code for nearby locations

This commit is contained in:
Laura Klünder 2019-12-24 23:01:30 +01:00
parent b7dd3a27fc
commit d1727a5a7b
2 changed files with 23 additions and 10 deletions

View file

@ -806,7 +806,10 @@ c3nav = {
if (c3nav._click_anywhere_popup) c3nav._click_anywhere_popup.remove(); if (c3nav._click_anywhere_popup) c3nav._click_anywhere_popup.remove();
} else { } else {
if ($(this).is('.select-point')) { if ($(this).is('.select-point')) {
c3nav._click_anywhere_load(); c3nav._click_anywhere_load(false);
} else if ($(this).is('.show-nearby')) {
c3nav._click_anywhere_load(true);
c3nav.update_state(false);
} }
} }
}, },
@ -1263,7 +1266,7 @@ c3nav = {
c3nav._click_anywhere_popup = popup; c3nav._click_anywhere_popup = popup;
popup.on('remove', function() { c3nav._click_anywhere_popup = null }).openOn(c3nav.map); popup.on('remove', function() { c3nav._click_anywhere_popup = null }).openOn(c3nav.map);
}, },
_click_anywhere_load: function() { _click_anywhere_load: function(nearby) {
if (!c3nav._click_anywhere_popup) return; if (!c3nav._click_anywhere_popup) return;
var latlng = c3nav._click_anywhere_popup.getLatLng(); var latlng = c3nav._click_anywhere_popup.getLatLng();
console.log(latlng); console.log(latlng);
@ -1276,13 +1279,23 @@ c3nav = {
$.getJSON('/api/locations/'+name+'/', function(data) { $.getJSON('/api/locations/'+name+'/', function(data) {
if (c3nav._click_anywhere_popup !== popup || !popup.isOpen()) return; if (c3nav._click_anywhere_popup !== popup || !popup.isOpen()) return;
popup.remove(); popup.remove();
newpopup = L.popup(c3nav._add_map_padding({className: 'location-popup', maxWidth: 500}, 'autoPanPaddingTopLeft', 'autoPanPaddingBottomRight')); if (nearby) {
var $destination = $('#destination-input');
c3nav._locationinput_set($destination, data);
} else {
newpopup = L.popup(c3nav._add_map_padding({
className: 'location-popup',
maxWidth: 500
}, 'autoPanPaddingTopLeft', 'autoPanPaddingBottomRight'));
var buttons = $('#location-popup-buttons').clone(); var buttons = $('#location-popup-buttons').clone();
buttons.find('.report-issue').remove(); buttons.find('.report-issue').remove();
buttons.find('.report').attr('href', '/report/l/' + String(data.id) + '/'); buttons.find('.report').attr('href', '/report/l/' + String(data.id) + '/');
newpopup.setLatLng(latlng).setContent(c3nav._build_location_html(data) + buttons.html()); newpopup.setLatLng(latlng).setContent(c3nav._build_location_html(data) + buttons.html());
c3nav._click_anywhere_popup = newpopup; c3nav._click_anywhere_popup = newpopup;
newpopup.on('remove', function() { c3nav._click_anywhere_popup = null }).openOn(c3nav.map); newpopup.on('remove', function () {
c3nav._click_anywhere_popup = null
}).openOn(c3nav.map);
}
}).fail(function() { }).fail(function() {
popup.remove(); popup.remove();
}); });

View file

@ -33,7 +33,7 @@
<div class="buttons"> <div class="buttons">
<button class="button-clear select-point"> <button class="button-clear select-point">
<i class="material-icons">pin_drop</i> <i class="material-icons">pin_drop</i>
{% trans 'Select this point' %} {% trans 'Show this point' %}
</button> </button>
</div> </div>
<div class="buttons"> <div class="buttons">