我试图在
https://developers.google.com/maps/articles/phpsqlinfo_v3
我想要一个取消和关闭按钮。所以,我修改了代码并将其上传到
http://adsany.com/testclose.htm (查看源代码)
当我点击地图时,会出现一个标记,
当我单击标记时,会出现信息窗口。
当我单击取消并关闭按钮时,它会关闭窗口,但会出现一个新标记。
所以,我想在不创建新标记的情况下关闭信息窗口。
请建议。
谢谢。
我试图在
https://developers.google.com/maps/articles/phpsqlinfo_v3
我想要一个取消和关闭按钮。所以,我修改了代码并将其上传到
http://adsany.com/testclose.htm (查看源代码)
当我点击地图时,会出现一个标记,
当我单击标记时,会出现信息窗口。
当我单击取消并关闭按钮时,它会关闭窗口,但会出现一个新标记。
所以,我想在不创建新标记的情况下关闭信息窗口。
请建议。
谢谢。
I hope this link will solve your Problem :-
http://gmaps-samples-v3.googlecode.com/svn/trunk/single-infowindow/single-infowindow.html.
<html>
<head>
<title>Single Info Windows</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
google.maps.event.addDomListener(window, 'load', function() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 13,
center: new google.maps.LatLng(37.789879, -122.390442),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var infoWindow = new google.maps.InfoWindow;
var onMarkerClick = function() {
var marker = this;
var latLng = marker.getPosition();
infoWindow.setContent('<h3>Marker position is:</h3>' +
latLng.lat() + ', ' + latLng.lng());
infoWindow.open(map, marker);
};
google.maps.event.addListener(map, 'click', function() {
infoWindow.close();
});
var marker1 = new google.maps.Marker({
map: map,
position: new google.maps.LatLng(37.789879, -122.390442)
});
var marker2 = new google.maps.Marker({
map: map,
position: new google.maps.LatLng(37.787814,-122.40764)
});
var marker3 = new google.maps.Marker({
map: map,
position: new google.maps.LatLng(37.767568,-122.391665)
});
google.maps.event.addListener(marker1, 'click', onMarkerClick);
google.maps.event.addListener(marker2, 'click', onMarkerClick);
google.maps.event.addListener(marker3, 'click', onMarkerClick);
});
</script>
<style type="text/css">
body {
font-family: sans-serif;
}
#map {
width: 500px;
height: 500px;
}
</style>
</head>
<body>
<h2>Demonstrates how to share a single info window on a map.</h2>
<ol>
<li>Click a marker to open a single info window containing the marker's position.</li>
<li>Close the opened info window by clicking anywhere on the map.</li>
</ol>
<div id="map"></div>
</body>
</html>