我在我的网站上使用此代码。 它显示带有标记的地图,当您点击标记时,您将转到另一页。 当你把光标放在标记上时你会看到标题,我需要总是显示标题。
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
<script type="text/javascript">
var points = [
["Page 1", 55.771683, 37.571274, 1, 'link to page 1'],
["Page 2", 55.7636, 37.606, 1, 'link to page 1']
];
function setMarkers(map, locations) {
var shape = {
coord: [1, 1, 1, 20, 18, 20, 18 , 1],
type: 'poly'
};
for (var i = 0; i < locations.length; i++) {
var flag = new google.maps.MarkerImage(
'http://googlemaps.googlermania.com/google_maps_api_v3/en/Google_Maps_Marker.png',
new google.maps.Size(37, 34),
new google.maps.Point(0,0),
new google.maps.Point(0, 19)
);
var place = locations[i];
var myLatLng = new google.maps.LatLng(place[1], place[2]);
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
icon: flag,
shape: shape,
title: place[0],
zIndex: place[3],
url: place[4]
});
google.maps.event.addListener(marker, 'click', function() {
// alert('go to ' + this.url); //
window.location.href = this.url;
});
}
}
function initialize() {
var myOptions = {
center: new google.maps.LatLng(55.766731,37.6010157,14),
zoom: 13,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
setMarkers(map, points);
}
</script>
<script type="text/javascript">
google.maps.event.addDomListener(window, 'load', initialize);
</script>
我的问题是我需要那个标题 - &gt; (标题:地方[0])总是显示。 现在,当我使用我的代码时,我会在标记上移动光标时看到标题。