1
我有一個Google地圖座標數組。每個座標集都有自己的標記。如果用戶將鼠標懸停(鼠標懸停)到另一個圖標上(這個圖標對所有標記都是相同的)。我的問題是,如果用戶做出鼠標輸出,我想恢復原始圖標,但是我只是獲取所有標記的最後創建的標記(marker3.png)。Google Maps API對標記鼠標移動的Javascript懸停效果
也許你有一個想法。這裏是腳本:
$(document).ready(function(){
var locations = [
['Dr. Christian Schrey', 52.499496, 13.316873, 4],
['Dr. Teufel', 52.528664, 13.380232, 5],
['Dr. Sebs Firma', 52.507839, 13.496490, 3],
];
initialize();
var map;
function initialize() {
var myLatlng = new google.maps.LatLng(52.52427, 13.40629);
var myOptions = {
zoom: 11,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("Map"), myOptions);
var infowindow = new google.maps.InfoWindow();
var marker, i;
var y = 0;
for (i = 0; i < locations.length; i++) {
y++;
image = 'http://xxx.de/test6/system/css/images/marker'+y+'.png';
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map,
icon: image
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(locations[i][0]);
infowindow.open(map, marker);
}
})(marker, i));
google.maps.event.addListener(marker, "mouseover", function(event) {
this.setIcon("http://xxx.de/test6/system/css/images/pfote_clean.png");
});
google.maps.event.addListener(marker, "mouseout", function(event) {
this.setIcon(image);
});
}
};
});
我感謝任何幫助!謝謝。
THX很多!這解決了它! :) – Sebsemillia 2012-03-08 17:23:58