有没有办法从外部链接激活谷歌地图上的信息窗口?html和js代码如下。
我想要一个简单的外部链接来激活标记的信息窗口。
任何帮助将不胜感激
萨贾:)
<!DOCTYPE html>
<html lang="en">
<head>
<title>Map</title>
<style>
#map{
width:640px;
height: 480px;
border:6px solid #6f5f5e;
margin:20px auto 30px auto;
}
</style>
</head>
<body>
<div class='container'>
<div id="map"> </div>
</div>
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="http://maps.google.com/maps/api/js?sensor=true" type="text/javascript"></script>
<script>
var markers = [
['Marker 1', 13.988719,100.617909],
['Marker 2.', 13.662811,100.43758],
['Marker 3', 13.744961,100.535073],
['Marker 4', 13.801981,100.613864],
['Marker 5', 13.767507,100.644024],
];
$(document).ready(function() {
var myOptions = {
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControl: false
};
var map = new google.maps.Map(document.getElementById("map"),myOptions);
var image = new google.maps.MarkerImage('img/marker.png',
new google.maps.Size(65, 32),
new google.maps.Point(0,0),
new google.maps.Point(18, 42)
);
var infowindow = new google.maps.InfoWindow();
var marker, i;
var bounds = new google.maps.LatLngBounds();
for (i = 0; i < markers.length; i++) {
var pos = new google.maps.LatLng(markers[i][1], markers[i][2]);
bounds.extend(pos);
marker = new google.maps.Marker({
position: pos,
map: map,
icon: image
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(markers[i][0]);
infowindow.open(map, marker);
}
})(marker, i));
}
map.fitBounds(bounds);
});
</script>
</body>