Download - LinuxFocus

Transcript
Views
$('#notifications').css ( 'color', 'blue' );
// Try to fetch the latitude/longitude of the browsing user
//and provides the callbacks
// Success: getLocation
// Failure: locationFail
navigator.geolocation.getCurrentPosition
(getLocation, locationFail);
}
else {
$('#notifications').html
( 'Sorry, your browser settings does not enable fetching your
Geolocation');
} // ends checkLocation()
//this is what happens if getCurrentPosition is successful
functiongetLocation(position) {
latitude = position.coords.latitude;
longitude = position.coords.longitude;
// Notify user for its location:
$('#notifications').html
( 'Your approx. position :
(' + latitude + ',' + longitude + ')' );
$('#notifications').css ( 'color', 'green' );
// Two seconds after the notification to user we have the
// location issue call to the controller to show it on
// the Google Map
setTimeout ( show_on_map, 2000);
}
//this is what happens if getCurrentPosition is unsuccessful
//(getCurrentPositionerrorCallback)
functionlocationFail() {
$('#notifications').html
('Sorry, your browser could not fetch your location ...');
$('#notifications').css ('color', 'red');
}
});
</script>
<!—As Before.. -->
<!—Notification selector -->
<HR></HR>
<DIV style='background:lightgreen;width:300px;'>
<span id='notifications'>...</span>
</DIV>
<HR></HR>
[ 160 ]