Fixes some issues with the location button being invisible (#207)

* Fakemobileclient should return a dict of wifi.data, instead of data, since we have bluetooth beacons too

* Use dict instead of list for beacon measurement in fakemobileclient and editor script

* Use distance directly

* BeaconMeasurementDataSchema add default

* Route from current location

* Do not try to set Score if no location found
This commit is contained in:
Jenny Paxian 2024-12-23 22:13:32 +01:00 committed by GitHub
parent 82b13e16a0
commit ebfc683f7c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 3 deletions

View file

@ -42,7 +42,7 @@ class PositioningResult(BaseSchema):
response={200: PositioningResult, **auth_responses}) response={200: PositioningResult, **auth_responses})
def get_position(request, parameters: LocateRequestSchema): def get_position(request, parameters: LocateRequestSchema):
try: try:
location = Locator.load().locate(parameters.dict()["wifi_peers"], location = Locator.load().locate(parameters.wifi_peers,
permissions=AccessPermission.get_for_request(request)) permissions=AccessPermission.get_for_request(request))
if location is not None: if location is not None:
# todo: this will overload us probably, group these # todo: this will overload us probably, group these

View file

@ -224,7 +224,8 @@ class Locator:
best_location = location best_location = location
best_score = score best_score = score
best_location.score = best_score if best_location is not None:
best_location.score = best_score
return best_location return best_location

View file

@ -1508,7 +1508,7 @@ c3nav = {
} }
// setup user location control // setup user location control
if (c3nav.ssids) c3nav._userLocationControl = new UserLocationControl().addTo(c3nav.map); if ($main.is('[data-ssids]')) c3nav._userLocationControl = new UserLocationControl().addTo(c3nav.map);
L.control.zoom({ L.control.zoom({
position: 'bottomright' position: 'bottomright'
@ -2036,6 +2036,7 @@ c3nav = {
} }
if (location) { if (location) {
$('.locationinput .locate, .leaflet-control-user-location a').text(c3nav._map_material_icon('my_location')); $('.locationinput .locate, .leaflet-control-user-location a').text(c3nav._map_material_icon('my_location'));
$('.locationinput .locate, .leaflet-control-user-location a').show();
var latlng = L.GeoJSON.coordsToLatLng(location.geometry.coordinates); var latlng = L.GeoJSON.coordsToLatLng(location.geometry.coordinates);
for (level in c3nav._userLocationLayers) { for (level in c3nav._userLocationLayers) {
if (!c3nav._userLocationLayers.hasOwnProperty(level)) continue; if (!c3nav._userLocationLayers.hasOwnProperty(level)) continue;
@ -2055,9 +2056,11 @@ c3nav = {
$('.leaflet-control-user-location a').toggleClass('control-disabled', false); $('.leaflet-control-user-location a').toggleClass('control-disabled', false);
} else if (c3nav.hasLocationPermission()) { } else if (c3nav.hasLocationPermission()) {
$('.locationinput .locate, .leaflet-control-user-location a').text(c3nav._map_material_icon('location_searching')); $('.locationinput .locate, .leaflet-control-user-location a').text(c3nav._map_material_icon('location_searching'));
$('.locationinput .locate, .leaflet-control-user-location a').show();
$('.leaflet-control-user-location a').toggleClass('control-disabled', false); $('.leaflet-control-user-location a').toggleClass('control-disabled', false);
} else { } else {
$('.locationinput .locate, .leaflet-control-user-location a').text(c3nav._map_material_icon('location_disabled')); $('.locationinput .locate, .leaflet-control-user-location a').text(c3nav._map_material_icon('location_disabled'));
$('.locationinput .locate, .leaflet-control-user-location a').hide();
$('.leaflet-control-user-location a').toggleClass('control-disabled', true); $('.leaflet-control-user-location a').toggleClass('control-disabled', true);
} }
if (typeof mobileclient !== 'undefined' && mobileclient.isCurrentLocationRequested && mobileclient.isCurrentLocationRequested()) { if (typeof mobileclient !== 'undefined' && mobileclient.isCurrentLocationRequested && mobileclient.isCurrentLocationRequested()) {