Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Fix #391 - Add dialogs for geolocation behaviors #396

Open
wants to merge 1 commit into
base: mobullityrebase
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 39 additions & 4 deletions src/client/js/otp/core/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,15 +277,50 @@ otp.core.Map = otp.Class({

// 40 accuracy for wifi, 22000 for wired/city center approximations
if (e.accuracy >= 22000) {
e.latlng = otp.config.initLatLng;
this.queueView(e.latlng, otp.config.initZoom);

dialogYesFn = (function(e, ctx) {
var original_pos = e;
var this_ = ctx;
return function() {
this_.queueView(original_pos.latlng, otp.config.initZoom);
webapp.map.geoLocationFound( original_pos );
}
})(e, this);

dialogNoFn = (function(e) {
var this_ = e;
return function() {
this_.queueView(otp.config.initLatLng, otp.config.initZoom);
}
})(this);

otp.widgets.Dialogs.showYesNoDialog("An inaccurate location was provided by your device. Would you like to use this anyway?", "Location Unavailable", dialogYesFn, dialogNoFn );

return; // dont bother adding a marker
}

// if e.latlng is outside of map boundaries (tampa), recenter on USF
if ( ! otp.config.mapBoundary.contains(e.latlng)) {
e.latlng = otp.config.initLatLng;
this.queueView(e.latlng, otp.config.initZoom);

dialogYesFn = (function(e, ctx) {
var original_pos = e;
var this_ = ctx;
return function() {
this_.queueView(original_pos.latlng, otp.config.initZoom);
webapp.map.geoLocationFound( original_pos );

}
})(e, this);

dialogNoFn = (function(e) {
var this_ = e;
return function() {
this_.queueView(otp.config.initLatLng, otp.config.initZoom);
}
})(this);

otp.widgets.Dialogs.showYesNoDialog("You appear to be outside of the Tampa area. Move the map to your current location now?", "Location Out of Range", dialogYesFn, dialogNoFn );

return; // and don't add a marker on first load
}

Expand Down