【发布时间】:2014-05-11 03:16:07
【问题描述】:
我知道已经有很多关于这个主题的问题 - 但我已经阅读了其中的许多问题,但似乎无法在我的特定情况下得到任何工作。我想用一堆自定义标记制作一张地图,其中包含显示澳大利亚各地商店位置的信息窗口(https://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclustererplus/examples/speed_test_example.html
以下是我的代码(目前我刚刚添加了 2 个城市的位置,例如,以后在全国有很多城市):
<!DOCTYPE html>
<html lang="en">
<head>
<title>Locations</title>
<meta charset="utf-8">
<script src="js/jquery-1.7.min.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerclustererplus/2.0.14/src/markerclusterer_packed.js"></script>
<script type="text/javascript">
var infowindow = null;
$(document).ready(function () { initialize(); });
function initialize() {
var centerMap = new google.maps.LatLng(-25.274398, 133.775136);
var myOptions = {
zoom: 4,
center: centerMap,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map"), myOptions);
var mc = new MarkerClusterer(map);
setMarkers(map, sites);
infowindow = new google.maps.InfoWindow({
content: "loading..."
});
}
var sites = [
['location 16', -37.814107 , 144.96328, 6, 'Description in info window','images/map_mobile.png'],
['location 5', -37.911394 , 145.189584, 5, 'Description in info window','images/map_store.png'],
['location 4', -33.963542 , 151.134273, 4, 'Description in info window','images/map_store.png'],
['location 3', -33.923960 , 150.921158, 3, 'Description in info window','images/map_store.png'],
['location 2', -34.065619 , 150.796491, 2, 'Description in info window','images/map_mobile.png'],
['location 1', -33.752178 , 150.6910478, 1, 'Description in info window','images/map_mobile.png']
];
function setMarkers(map, markers) {
for (var i = 0; i < markers.length; i++) {
var sites = markers[i];
var siteLatLng = new google.maps.LatLng(sites[1], sites[2]);
var marker = new google.maps.Marker({
position: siteLatLng,
map: map,
title: sites[0],
zIndex: sites[3],
html: sites[4],
icon: sites[5]
});
google.maps.event.addListener(marker, "click", function () {
//alert(this.html);
infowindow.setContent(this.html);
infowindow.open(map, this);
});
}
}
</script>
</head>
<body onload="initialize()">
<div id="map" style="width: 620px; height: 600px;"></div>
</body>
</html>
总之,我需要帮助来获得集群工作和 html 链接...
【问题讨论】:
标签: javascript google-maps google-maps-api-3 google-maps-markers