基本的にはマップクラスターを持っていて、クラスターをクリックして個々のマップマーカーをクリックすると別のページにリンクされます私のウェブサイトでマーカークラスターのマップマーカーにURLを追加google map 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