How to integrate SearchBox in Google Maps JavaScript API v3?

拟墨画扇 提交于 2019-12-01 12:31:50

You also have to load the Places Search Box:

var searchBox = new google.maps.places.SearchBox(input, {
  bounds: defaultBounds // have to be defined first
});

Then you can listen to the places_changed event:

google.maps.event.addListener(searchBox, 'places_changed', function() {
      var places = searchBox.getPlaces();
      // do your stuff here
});

Have a look at the source code of the example page you posted to get an idea of what to do in there, for example drawing markers etc.

You can find more information in the SearchBox API Documentation.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!