From 72f90b98519ff66210aea15562f0ed18d49289d9 Mon Sep 17 00:00:00 2001 From: jmfield2 Date: Fri, 30 Dec 2016 01:10:48 -0500 Subject: [PATCH] Fix #391 - Add dialogs describing the app behavior when location is out of the map bounds, or accuracy is too high and prompts the user to optionally ignore the error and move the map anyway. --- src/client/js/otp/core/Map.js | 43 +++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/src/client/js/otp/core/Map.js b/src/client/js/otp/core/Map.js index 008683337..d4547857d 100644 --- a/src/client/js/otp/core/Map.js +++ b/src/client/js/otp/core/Map.js @@ -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 }