EDIT 4地圖不上點擊鼠標與谷歌地圖API V3響應和QWebView
所有這一切,而我就在想,這是標記問題,即他們沒有得到拖! 現在我已經意識到,當它在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>
雖然使用Google API ** V2 **的人不需要此代碼,因爲API ** V2 **不存在此問題。 – 2011-06-04 07:42:45