【发布时间】:2023-04-05 17:28:01
【问题描述】:
仅在地址变量上工作的代码。 所以在选择选项值有多个地址。
function geocodeAddress(geocoder, resultsMap) {
var address = document.getElementById('Select').value;
for(i = 0; i < address.length;i++){
geocoder.geocode({'address': address[i]}, function(results, status) {
if (status === google.maps.GeocoderStatus.OK) {
// resultsMap.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: resultsMap,
position: results[i].geometry.location
});
markers.push(marker);
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
}
}
【问题讨论】: