aboutsummaryrefslogtreecommitdiffstats
path: root/web/js/fixmystreet.js
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2011-09-07 09:49:10 +0100
committerStruan Donald <struan@exo.org.uk>2011-09-07 09:49:10 +0100
commit82b093ae5b2f313c1393efb2b26e12563c2aaa5f (patch)
treefde92abd3d37d7f03dda3c6d69df07d26c8b06b3 /web/js/fixmystreet.js
parentb71f5857ecf50a78e13fe521986f49e304f0a7bf (diff)
parent4cdc50037c8abb27744d672a2ad496bb27086652 (diff)
Merge branch 'master' of ssh://git.mysociety.org/data/git/public/fixmystreet into js-validation
Conflicts: templates/web/default/common_header_tags.html
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 edab0b5ba..2c404af93 100644
--- a/web/js/fixmystreet.js
+++ b/web/js/fixmystreet.js
@@ -124,4 +124,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
+ });
+ });
+ }
+
});