我的搜索框曾经工作过。但现在它没有用。我不明白为什么。 你能帮忙吗? 我的代码在这里;
<input id="pac-input" type="text" size="50"><div id="dvMap"style="width: 900px; height: 500px"></div><script type="text/javascript">
var input = document.getElementById('pac-input');
var marker;
var markers = [];
var searchBox = new google.maps.places.SearchBox(input);
google.maps.event.addListener(searchBox, 'places_changed', function (e) {
for (var i = 0; i < markers.length; i++) { markers[i].setMap(null); }
var places = searchBox.getPlaces();
var bounds = new google.maps.LatLngBounds();
var place;
marker = new google.maps.Marker({ map: map });
for (i = 0; place = places[i]; i++) {
bounds.extend(place.geometry.location);
marker.setPosition(place.geometry.location);
}
markers.push(marker);
map.fitBounds(bounds);
map.setZoom(17);
});