3
我有這裏的情況,請幫助我解決此問題
在具有多個標記的地圖上,我使用了兩個經度和緯度變量,並將它們用作中心點地圖。如何突出多標記地圖上的特定標記
我怎樣才能
- 使用標記爲這些經/緯用於中心的反彈或
動畫 - 改變這個中心標記的圖標比其他人不同的
- 添加額外的信息框中的信息。
在此先感謝您的幫助
-----這裏是代碼
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Google Maps Multiple Markers</title>
<script src="http://maps.google.com/maps/api/js?sensor=false"
type="text/javascript"></script>
</head>
<body>
<div id="map" style="width: 500px; height: 400px;"></div>
<script type="text/javascript">
var locations = [
['Bondi Beach', -33.890542, 151.274856, 4],
['Coogee Beach', -33.923036, 151.259052, 5],
['Cronulla Beach', -34.028249, 151.157507, 3],
['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
['Maroubra Beach', -33.950198, 151.259302, 1]
];
var lat1 = '-33.92'
var long1 = '151.25'
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 10,
center: new google.maps.LatLng(lat1, long1),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var infowindow = new google.maps.InfoWindow();
var marker, i;
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(locations[i][0]);
infowindow.open(map, marker);
}
})(marker, i));
}
</script>
</body>
</html>
非常感謝alkis 它的工作原理完善只用一個小毛刺 請考慮在代碼中的位置的這個 塊是靜態的,總會有5項,包括庫吉海灘 結果會有現在的Coogee海灘 重複標記6個標記怎樣才能刪除/更新coogee沙灘標記,這樣只有地圖上只有5個標記,而更新的標記是新的 –
我更新了代碼。如果這回答你的問題,不要忘記標記爲回答,也許upvote:P。 – alkis
alkis,你是一個明星......它的工作就像一個魅力......我希望如果我可以upvote到答案,但沒有足夠的聲譽計數 –