Skip to content

Instantly share code, notes, and snippets.

@pilate
Created December 29, 2010 00:38
Show Gist options
  • Save pilate/757964 to your computer and use it in GitHub Desktop.
Save pilate/757964 to your computer and use it in GitHub Desktop.
centerMapOnCity: function() {
var that = this;
this.deleteOverlays();
var entered_city = $("post_location_name").value;
if(entered_city) {
var city = "", state = "", country = "";
this.geocoder.geocode( { 'address': entered_city}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var latlng = results[0].geometry.location;
general_location = that.getGeneralLocation('address', results);
if (general_location != null) {
$("post_location_name").value = general_location;
zoom = 10;
map.setCenter(latlng);
map.setZoom(10);
$('general_location').innerHTML = general_location; // set the label for the address field
Posts.toggleAddress();
} else {
alert("Please enter a more specific location, like a city name.");
}
} else {
alert("Couldn't find that location, try again!");
}
});
}
setTimeout(checkCanSubmit, 200);
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment