编辑 4
一直以来,我一直在想这是标记的问题,它们不会被拖拽!现在我已经意识到,当地图显示在 Qt 小部件中时,没有鼠标点击在地图上起作用。
以下代码,我粘贴在一个 HTML 文件中并通过 Firefox 打开,这完美无瑕!当我单击 QtWidget 上的地图时,同样没有响应:rolleyes:
谁能为我确认这一点或告诉我我做错了什么?
谷歌地图 JavaScript API 示例
<script type="text/javascript">
var map;
var latlng = new google.maps.LatLng (34.7607233, -117.0107599);
var directionsDisplay = new google.maps.DirectionsRenderer ();;
var directionsService = new google.maps.DirectionsService ();
var pointsArray = new Array();
var arrayToBeReturned = new Array();
function initialize ()
{
var myOptions =
{
zoom:8,
center:latlng,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map (document.getElementById ("map"), myOptions);
directionsDisplay.setMap (map);
google.maps.event.addListener (map, "click", function ()
{
alert("You clicked the map.");
});
}
</script>
</head>
<body onload="initialize()" topmargin="0" leftmargin="0">
<div id="map" style="width: 341px; height: 271px"></div>
<div id="directionsPanel" style="float:right;width:30%;height 100%"></div>
</body>
</html>