diff options
Diffstat (limited to 'www/js/views')
-rw-r--r-- | www/js/views/around.js | 44 | ||||
-rw-r--r-- | www/js/views/fms.js | 4 | ||||
-rw-r--r-- | www/js/views/home.js | 1 |
3 files changed, 42 insertions, 7 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, _, $); diff --git a/www/js/views/fms.js b/www/js/views/fms.js index d827445..384d125 100644 --- a/www/js/views/fms.js +++ b/www/js/views/fms.js @@ -29,6 +29,10 @@ this.navigate( this.next, 'left' ); }, + displayError: function(msg) { + alert(msg); + }, + destroy: function() { console.log('destory for ' + this.id); this.remove(); } }) }); diff --git a/www/js/views/home.js b/www/js/views/home.js index cfa6167..e29534e 100644 --- a/www/js/views/home.js +++ b/www/js/views/home.js @@ -29,7 +29,6 @@ localStorage.offline = 1; FMS.router.navigate( 'no_connection' ); } else { - alert('pause'); FMS.router.navigate( 'around', { trigger: true } ); } } |