Created
September 13, 2012 17:37
-
-
Save SpencerCooley/3716085 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var geocoder = new google.maps.Geocoder(); | |
$("#address").autocomplete({ | |
//This bit uses the geocoder to fetch address values | |
source: function(request, response) { | |
geocoder.geocode( {'address': request.term }, function(results, status) { | |
response($.map(results, function(item) { | |
return { | |
label: item.formatted_address, | |
value: item.formatted_address, | |
latitude: item.geometry.location.lat(), | |
longitude: item.geometry.location.lng() | |
} | |
})); | |
}) | |
}, | |
//This bit is executed upon selection of an address | |
select: function(event, ui) { | |
$("#lat").val(ui.item.latitude); | |
$("#lng").val(ui.item.longitude); | |
} | |
}); | |
//the css | |
.ui-autocomplete { | |
background-color: white; | |
width: 300px; | |
border: 1px solid #cfcfcf; | |
list-style-type: none; | |
padding-left: 0px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment