我正在努力通过Google地图API来创建多个标记,每个标记都有一个链接。作为一个javascript noob也没有帮助。
到目前为止,这是我的代码:
<div id="map"></div>
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 12,
center: {lat: -27.469703, lng: 153.025190}
});
// Create an array of alphabetical characters used to label the markers.
var labels = 'X';
// 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,
label: labels[i % labels.length]
});
});
// 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: -27.449916, lng: 153.044031},
{lat: -27.476536, lng: 153.020148},
]
</script>
<script src="https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/markerclusterer.js">
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=APIKEYHERE&callback=initMap">
地图显示正常,标记在那里,但我试图实现链接的所有内容都失败了。
提前致谢!
答案 0 :(得分:0)
您需要为每个标记添加点击侦听器。见下文:
repositories/test/com/my-company/a/b/c/1.1.0/some-folder
repositories/test/com/my-company/a/b/c/1.1.0-SNAPSHOT/some-folder