diff options
author | Struan Donald <struan@exo.org.uk> | 2013-08-05 12:45:41 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2013-08-05 12:45:41 +0100 |
commit | b10b6a8434eb1993b7ff01509f6af614e2c63d3a (patch) | |
tree | cde74c5166b92e383a6236ae2414a0eeef7e9138 | |
parent | f00da917bb9f5881cbf7b910647ddb5d233b612f (diff) |
Display reposition report button after recentering map
If recentering the map moves the crosshair position to somewhere
different to the current report location then display the reposition
button. Includes small margin of error for GPS noise etc.
Fixes #75
-rw-r--r-- | src/js/views/around.js | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/js/views/around.js b/src/js/views/around.js index 62f1ac1..df2bd89 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(); + } + } } }, @@ -420,10 +437,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") |