aboutsummaryrefslogtreecommitdiffstats
path: root/web/js/fixmystreet.js
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2011-09-07 16:50:39 +0100
committerStruan Donald <struan@exo.org.uk>2011-09-07 16:50:39 +0100
commit1fd3b3ff6ab2a1c985d22249343c96a3f0178651 (patch)
tree1c1e933664da42daa673aadf3416e783975708e1 /web/js/fixmystreet.js
parent05f3184cf309c2d9adc631c37b293bf43fc2ee49 (diff)
parent4cdc50037c8abb27744d672a2ad496bb27086652 (diff)
Merge branch 'master' of ssh://git.mysociety.org/data/git/public/fixmystreet
Diffstat (limited to 'web/js/fixmystreet.js')
-rw-r--r--web/js/fixmystreet.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/web/js/fixmystreet.js b/web/js/fixmystreet.js
index 4b19dc53e..b67c4d74b 100644
--- a/web/js/fixmystreet.js
+++ b/web/js/fixmystreet.js
@@ -57,4 +57,32 @@ $(function(){
timer = window.setTimeout(email_alert_close, 2000);
});
+ // Geolocation
+ if (geo_position_js.init()) {
+ $('#postcodeForm').append('<p id="geolocate_para">Or <a href="#" id="geolocate_link">locate me automatically</a>').css({ "padding-bottom": "0.5em" });
+ $('#geolocate_link').click(function(e) {
+ e.preventDefault();
+ // Spinny thing!
+ $('#geolocate_para').append(' <img src="/i/flower.gif" alt="" align="bottom">');
+ geo_position_js.getCurrentPosition(function(pos) {
+ $('#geolocate_para img').remove();
+ var latitude = pos.coords.latitude;
+ var longitude = pos.coords.longitude;
+ location.href = '/around?latitude=' + latitude + ';longitude=' + longitude;
+ }, function(err) {
+ $('#geolocate_para img').remove();
+ if (err.code == 1) { // User said no
+ } else if (err.code == 2) { // No position
+ $('#geolocate_para').html("Could not look up location");
+ } else if (err.code == 3) { // Too long
+ $('#geolocate_para').html("No result returned");
+ } else { // Unknown
+ $('#geolocate_para').html("Unknown error");
+ }
+ }, {
+ timeout: 10000
+ });
+ });
+ }
+
});