我在地图上点击鼠标时使用以下代码显示jQuery UI对话框:
GEvent.addListener(map, "click", clicked);
function clicked(overlay, latlng) {
$('#dialog').show();
};
单击的函数和show()函数都可以自行运行,但是当我想通过单击地图打开对话框时它不会。有什么想法吗?
答案 0 :(得分:1)
您可能需要查看以下示例:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Google Maps jQuery UI Demo</title>
<link type="text/css" href="themes/base/jquery.ui.all.css" rel="stylesheet" />
<script src="http://maps.google.com/maps?file=api&v=2&sensor=false"
type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.4.2.min.js"
type="text/javascript"></script>
<script src="jquery-ui-1.8.custom.min.js" type="text/javascript"></script>
</head>
<body onunload="GUnload()">
<div id="map" style="width: 450px; height: 300px"></div>
<div id="dialog" title="Basic Dialog" style="display: none;">Dialog</div>
<script type="text/javascript">
var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(37.4419, -122.1419), 13);
GEvent.addListener(map, "click", function(overlay, latlng) {
$('#dialog').dialog();
});
</script>
</body>
</html>
截图:
alt text http://img517.imageshack.us/img517/643/jquerygoogle.png