Skip to content

Instantly share code, notes, and snippets.

@zkwentz
Forked from badsyntax/gist:4330899
Last active December 18, 2015 22:28
Show Gist options
  • Save zkwentz/5854534 to your computer and use it in GitHub Desktop.
Save zkwentz/5854534 to your computer and use it in GitHub Desktop.
Update to use TagsManager
/**
* Threw together by Richard Willis - badsyntax.co
*/
var service = new google.maps.places.AutocompleteService();
var geocoder = new google.maps.Geocoder();
var $location = $('#locationField');
$location.typeahead({
source: function(query, process) {
service.getPlacePredictions({ input: query }, function(predictions, status) {
if (status == google.maps.places.PlacesServiceStatus.OK) {
process($.map(predictions, function(prediction) {
return prediction.description;
}));
}
});
},
updater: function (item) {
geocoder.geocode({ address: item }, function(results, status) {
if (status != google.maps.GeocoderStatus.OK) {
alert('Cannot find address');
return;
}
map.setCenter(results[0].geometry.location);
map.setZoom(12);
});
return item;
}
});
$location.tagsManager({
typeahead: true,
backspace: [8],
blinkBGColor_1: '#FFFF9C',
blinkBGColor_2: '#CDE69C',
delimiters: [13],
deleteTagsOnBackspace: true,
tagClass: 'tm-tag-inverse',
minLength: 2,
tagCloseIcon: '×',
onlyTagList: true,
maxTags: 1
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment