aboutsummaryrefslogtreecommitdiffstats
path: root/www/js/views/around.js
diff options
context:
space:
mode:
Diffstat (limited to 'www/js/views/around.js')
-rw-r--r--www/js/views/around.js44
1 files changed, 38 insertions, 6 deletions
diff --git a/www/js/views/around.js b/www/js/views/around.js
index ba0e62e..02f7cc0 100644
--- a/www/js/views/around.js
+++ b/www/js/views/around.js
@@ -6,13 +6,45 @@
id: 'around-page',
afterDisplay: function() {
- console.log( 'around after display');
- fixmystreet.latitude = 56.33182;
- fixmystreet.longitude = -2.79483;
+ this.locate();
+ },
- show_map();
- console.log('map shown');
- }
+ locate: function() {
+ var that = this;
+ var l = new Locate();
+ _.extend(l, Backbone.Events);
+ l.on('located', this.showMap, this );
+ l.on('failed', this.noMap, this );
+
+ l.geolocate();
+ },
+
+ showMap: function( info ) {
+ var coords = info.coordinates;
+ fixmystreet.latitude = coords.latitude;
+ fixmystreet.longitude = coords.longitude;
+ if ( !fixmystreet.map ) {
+ show_map();
+ } else {
+ var centre = new OpenLayers.LonLat( coords.longitude, coords.latitude );
+ centre.transform(
+ new OpenLayers.Projection("EPSG:4326"),
+ fixmystreet.map.getProjectionObject()
+ );
+ fixmystreet.map.panTo(centre);
+ }
+ },
+
+ noMap: function( details ) {
+ $('#ajaxOverlay').hide();
+ if ( details.msg ) {
+ this.displayError( details.msg );
+ } else if ( details.locs ) {
+ this.displayError( STRINGS.multiple_locations );
+ } else {
+ this.displayError( STRINGS.location_problem );
+ }
+ },
})
});
})(FMS, Backbone, _, $);