我有这个功能:
function createMarkersForPlaces(places, infowindow) {
for (var i = 0; i < places.length; i++) {
var place = places[i];
var marker = new google.maps.Marker({
map: map,
title: place.name,
position: place.geometry.location,
id: place.place_id,
animation: google.maps.Animation.DROP
});
placeMarkers.push(marker);
// if user clicks one of the marker, execute getPlaceDetails
// for that specific place
marker.addListener('click', function() {
if (infowindow.marker == this) {
} else {
getPlacesDetails(this, infowindow);
}
});
// based on the places above, populate list in html
$("ul").append("<li><a href='#' onclick='getPlacesDetails(" + …Run Code Online (Sandbox Code Playgroud)