我正在尝试将InfoWindow放在与MarkerClusterer分组的多个标记中,但没有成功.我只能生成带有infowindows或带有集群的地图; 不是两个在同一时间.在网上搜索让我更加困惑....
起点是谷歌开发者页面:根据我的需求,我创建了以下代码:
<div id="map"></div>
<script>
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 5,
center: {lat: -15.7942357, lng: -47.8821945}
});
// Add some markers to the map.
// Note: The code uses the JavaScript Array.prototype.map() method to
// create an array of markers based on a given "locations" array.
// The map() method here has nothing to do with the Google Maps API.
var markers = locations.map(function(location, i) {
return new google.maps.Marker({
position: location,
}); …Run Code Online (Sandbox Code Playgroud)