我正在使用以下腳本來顯示帶有兩個標記的地圖。如果我將鼠標懸停在標記上,則會彈出一個工具提示。我的問題是我如何獲得默認顯示的信息,而不是mousehover?如何讓地圖工具提示默認顯示,而不是鼠標懸停?
google.maps.event.addDomListener(window, 'load', init);
var map;
function init() {
var mapOptions = {
center: new google.maps.LatLng(37.1370345, 74.3872165),
zoom: 3,
zoomControl: true,
zoomControlOptions: {
style: google.maps.ZoomControlStyle.SMALL,
},
disableDoubleClickZoom: false,
mapTypeControl: false,
scaleControl: true,
scrollwheel: false,
streetViewControl: true,
draggable: true,
overviewMapControl: false,
mapTypeId: google.maps.MapTypeId.ROADMAP,
styles: [{
"featureType": "administrative",
"elementType": "labels.text.fill",
"stylers": [{
"color": "#444444"
}]
}, {
"featureType": "landscape",
"elementType": "all",
"stylers": [{
"color": "#111111"
}, {
"lightness": 50
}]
}, {
"featureType": "poi",
"elementType": "all",
"stylers": [{
"visibility": "off"
}]
}, {
"featureType": "road",
"elementType": "all",
"stylers": [{
"saturation": -100
}, {
"lightness": 45
}]
}, {
"featureType": "road.highway",
"elementType": "all",
"stylers": [{
"visibility": "on"
}]
}, {
"featureType": "road.arterial",
"elementType": "labels.icon",
"stylers": [{
"visibility": "off"
}]
}, {
"featureType": "transit",
"elementType": "all",
"stylers": [{
"visibility": "off"
}]
}, {
"featureType": "water",
"elementType": "all",
"stylers": [{
"color": "#ffffff"
}, {
"visibility": "on"
}]
}],
}
var mapElement = document.getElementById('map1');
var map = new google.maps.Map(mapElement, mapOptions);
var locations = [
['Country 1', 39.690642467918366, 39.07426848448813],
['Country 2', 39.682790, 19.764394]
];
var infowindow = new google.maps.InfoWindow({
content: "Loading..."
});
var myIcon = new google.maps.MarkerImage("http://i.imgur.com/jRfjvrz.png", null, null, null, new google.maps.Size(46, 46));
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
content: locations[i][0],
icon: myIcon,
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
animation: google.maps.Animation.DROP,
optimized: false,
map: map
});
google.maps.event.addListener(marker, 'mouseover', function() {
infowindow.setContent(this.content);
infowindow.open(map, this);
});
}
}
店的彈出窗口的一個數組/對象,然後簡單的調用'每一個 – atmd