기본적으로 내가하려는 것은지도 클러스터가있는 것이고 일단 클러스터를 클릭하고 개별 맵 마커를 클릭하면 다른 페이지로 연결됩니다 내 웹 사이트에.마커 클러스터에서지도 마커에 URL을 추가 google지도 API
이것은 내가 지금까지 가지고있는 것입니다. 하지만 난 .. 통해 다른 마커로 URL을 끌어 것 같습니다.
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 4,
center: {lat: -39.3642, lng: 164.0444318}
});
// 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,
url: "http://travelpark.co.nz" //Will be different for each marker
});
});
// Add a marker clusterer to manage the markers.
var markerCluster = new MarkerClusterer(map, markers,
{imagePath: 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m'});
}
var locations = [
{lat: -37.7862985, lng: 175.2773836},
{lat: -37.8011434, lng: 174.871265}
]
google.maps.event.addListener(markers, 'click', function() {
window.location.href = this.url;
});
하단의 이벤트 수신기는 작동하지 않습니다.이 문제를 파악하는 것 같습니다. 어떤 도움을받을 수 있습니까?
배열에 리스너를 지정하려고합니다. foreach를 사용하여 해당 배열의 각 표식 객체에 개별적으로 할당합니다. – dev8080