Created
April 9, 2015 10:10
-
-
Save xfstart07/d357778010fee053905c 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
| /** | |
| * 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