diff options
author | Jedidiah Broadbent <hello@jedidiah.eu> | 2013-08-06 10:45:51 +0100 |
---|---|---|
committer | Jedidiah Broadbent <hello@jedidiah.eu> | 2013-08-06 10:45:51 +0100 |
commit | bf03d5d7697aa41dcc9de39ab6ac3e5e8f79aa9a (patch) | |
tree | 90419a714381c458c583eac1bc40d79cdfb638d4 /src/js/views/around.js | |
parent | 1b6cf6dcc2758b2c3ca5e8a5ff4b06d83132d072 (diff) | |
parent | 3cb1cc455210fa60fb44fbb105e733378699c2a9 (diff) |
Merge branch 'master' of ssh://git.mysociety.org/data/git/public/fixmystreet-mobile
Diffstat (limited to 'src/js/views/around.js')
-rw-r--r-- | src/js/views/around.js | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/js/views/around.js b/src/js/views/around.js index 1315710..501c371 100644 --- a/src/js/views/around.js +++ b/src/js/views/around.js @@ -140,6 +140,23 @@ // is up so we probably should not recenter if ( FMS.currentPosition ) { fixmystreet.map.panTo(this.projectCoords( FMS.currentPosition )); + + // If we've confirmed the report position then we should be able + // to reposition it if we've moved the map. + if ( $('#confirm').css('display') == 'block' ) { + var currentPos = this.projectCoords(FMS.currentPosition); + var markerPos = this.getMarkerPosition(true); + + // Displaying the button if the report is in the same place as the + // GPS location could be confusing so check they are different. + // The slight margin of error is there to account for both rounding + // wiggle in the projectCoords and also so that small changes due to + // GPS noise are ignored + if ( Math.abs(markerPos.lat - currentPos.lat) > 1 || + Math.abs(markerPos.lon - currentPos.lon) > 1 ) { + $('#reposition').show(); + } + } } }, @@ -155,7 +172,7 @@ if ( !fixmystreet.map ) { $('#relocate').hide(); $('#mark-here').hide(); - $('#pc').attr('Search for a place or postcode.').focus(); + $('#pc').attr('placeholder', 'Search for a place or postcode.').focus(); } $('#front-howto').html('<p>' + msg + '</msg>'); $('#front-howto').show(); @@ -291,7 +308,8 @@ }, searchSuccess: function( info ) { - this.stopListening(FMS.locator); + this.stopListening(FMS.locator, 'search_located'); + this.stopListening(FMS.locator, 'search_failed'); var coords = info.coordinates; if ( fixmystreet.map ) { fixmystreet.map.panTo(this.projectCoords( coords )); @@ -335,7 +353,8 @@ searchFail: function( details ) { // this makes sure any onscreen keyboard is dismissed $('#submit').focus(); - this.stopListening(FMS.locator); + this.stopListening(FMS.locator, 'search_located'); + this.stopListening(FMS.locator, 'search_failed'); if ( details.msg ) { this.searchError( details.msg ); } else if ( details.locations ) { @@ -420,10 +439,13 @@ return position; }, - getMarkerPosition: function() { + getMarkerPosition: function(skipTransform) { var marker = fixmystreet.report_location.features[0].geometry; var position = new OpenLayers.LonLat( marker.x, marker.y ); + if ( skipTransform ) { + return position; + } position.transform( fixmystreet.map.getProjectionObject(), new OpenLayers.Projection("EPSG:4326") |