aboutsummaryrefslogtreecommitdiffstats
path: root/web/js/fixmystreet.js
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2011-09-08 10:05:06 +0100
committerStruan Donald <struan@exo.org.uk>2011-09-08 10:05:06 +0100
commitb1bd589b2fc8075cab39679d23db2b7d285f8345 (patch)
tree933ce962203f846d6d53b53851b36949f921a869 /web/js/fixmystreet.js
parentba9172907f5e41840cf5324cc335277bbd031ed2 (diff)
parent3423cfe5e16e9130a25238cd76de76ec2bf07c67 (diff)
Merge branch 'master' of ssh://git.mysociety.org/data/git/public/fixmystreet into open311-consumer
Conflicts: web/css/core.css web/js/fixmystreet.js
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 9fa0f948b..48d66360b 100644
--- a/web/js/fixmystreet.js
+++ b/web/js/fixmystreet.js
@@ -83,4 +83,32 @@ $(function(){
}
});
+ // 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
+ });
+ });
+ }
+
});