Skip to content

Instantly share code, notes, and snippets.

@whardier
Created April 20, 2013 22:17
Show Gist options
  • Save whardier/5427651 to your computer and use it in GitHub Desktop.
Save whardier/5427651 to your computer and use it in GitHub Desktop.
diff --git a/app/assets/javascripts/main.js.erb b/app/assets/javascripts/main.js.erb
index 0211f0a..6eef6b2 100644
--- a/app/assets/javascripts/main.js.erb
+++ b/app/assets/javascripts/main.js.erb
@@ -132,6 +132,21 @@ $(function() {
var center = map.getCenter();
addMarkersAround(center.lat(), center.lng());
});
+
+ function detect_location_error(err) {
+ alert("There was an error detecting your location.. and I'm a useless alert.");
+ };
+
+ function detect_location_update(msg) {
+ var latitude = msg.coords.latitude;
+ var longitude = msg.coords.longitude;
+ var latlng = new google.maps.LatLng(latitude, longitude);
+ map.panTo(latlng);
+ };
+
+ // Attempt to detect location
+ navigator.geolocation.getCurrentPosition(detect_location_update, detect_location_error);
+
$('#address_form').live('submit', function() {
var submitButton = $("#address_form input[type='submit']");
$(submitButton).attr("disabled", true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment