Skip to content

Instantly share code, notes, and snippets.

@xfstart07
Created April 9, 2015 10:10
Show Gist options
  • Select an option

  • Save xfstart07/d357778010fee053905c to your computer and use it in GitHub Desktop.

Select an option

Save xfstart07/d357778010fee053905c to your computer and use it in GitHub Desktop.
谷歌地图 关键字地区搜索
/**
* Created by xufei on 4/9/15.
*/
function search_box_gmaps() {
var input = $('.pac-input').each(function(index, element) {
var searchBox = new google.maps.places.SearchBox(element);
google.maps.event.addListener(searchBox, 'places_changed', function() {
var places = searchBox.getPlaces();
$("p#select_region").text(places[0].address_components[places[0].address_components.length-1].short_name);
if (places.length == 0) {
return;
}
});
});
}
google.maps.event.addDomListener(window, 'load', search_box_gmaps);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment