Permalink
Browse files

resolves #44 -- default to last location

  • Loading branch information...
1 parent 7396029 commit d715b66efec626bc2f7a278795891e018d3f560a rnagle committed Jan 29, 2011
View
@@ -1,4 +1,5 @@
*.pyc
*.swp
.DS_Store
-*sass-cache
+*sass-cache
+local_settings.py
@@ -68,15 +68,22 @@ function handle_geocode(results, status) {
lat = results[0].geometry.location.lat();
lng = results[0].geometry.location.lng();
-
+
+ last_location = [lat, lng];
+
normalized_address = results[0].formatted_address;
$('#location-form #address').val(normalized_address);
process_location(lat, lng);
+ save_last_location(last_location);
}
function geolocate() {
- if (navigator.geolocation) {
+ if (check_saved_location()) {
+ last_location = store.get('last_location');
+
+ geocode(new google.maps.LatLng(last_location[0], last_location[1]));
+ } else if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(geolocation_success, geolocation_error);
} else {
process_location(41.890498, -87.62361);
@@ -111,6 +118,28 @@ function process_location(lat, lng) {
get_boundaries(lat, lng);
}
+function save_last_location(location) {
+ store.set('last_location', location);
+}
+
+function get_last_location() {
+ last_location = store.get('last_location');
+ return last_location;
+}
+
+function clear_last_location() {
+ store.remove('last_location');
+}
+
+function check_saved_location() {
+ last_location = store.get('last_location');
+ if (last_location) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
function alt_addresses(results) {
$('#alt-addresses').html('');
@@ -1,5 +1,7 @@
{% extends 'base.html' %}
+{% load newsappstags %}
+
{% block title %}You are here.{% endblock %}
{% block content %}
@@ -33,6 +35,8 @@ <h1 id="page-title">You are here.</h1>
{% block foot %}
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
+<script type="text/javascript" src="{% build_media_url '/site_media/js/store.js' %}"></script>
+<script type="text/javascript" src="{% build_media_url '/site_media/js/json.js' %}"></script>
<script type="text/javascript">
{{ demo_js }}
</script>
Oops, something went wrong.

0 comments on commit d715b66

Please sign in to comment.