1
A
回答
1
您可以通過偵聽mouseup或click事件,然後使用填充疊加技術來顯示自定義上下文菜單來實現此目的。
事件偵聽器的代碼將如下所示。
// Listen for all mouseup events in the plugin.
// Where 'ge' is an instance of the GEPlugin
google.earth.addEventListener(ge.getWindow(), 'mouseup', eventHandler);
事件處理程序將類似於以下內容。
// Handles mouseup events (e is a KmlMouseEvent)
var eventHandler = function(e)
{
// if it is a right-click
if (e && e.getButton() == 2)
{
event.preventDefault(); // optional, depending on your requirements
event.stopPropagation(); // optional, depending on your requirements
openMenu(e.getScreenX(), e.getScreenY());
}
}
最後,打開自定義菜單的代碼將如下所示。
// Insert a custom iframe at the x, y screen position
var openMenu = function(x, y)
{
var iframe = document.createElement('iframe');
iframe.frameBorder = 0;
iframe.scrolling = 'no';
iframe.style.position = 'absolute';
// build the menu as you require...
// then position and show it.
iframe.style.left = x + 'px';
iframe.style.top = y + 'px'; // you may want to offset the position...
document.body.appendChild(iframe); // show the menu
}
很明顯,您在菜單中放入的內容以及樣式取決於您。你也可能想要隱藏它,這只是一個刪除iframe的情況 - 可能在另一個菜單項上的監聽器(例如,當你點擊菜單項時菜單消失)
如果你在這裏被卡住是與事件合作的重要參考。 https://developers.google.com/earth/documentation/events
而且,這裏是iframe的墊片技術的工作示例: http://earth-api-samples.googlecode.com/svn/trunk/demos/customcontrols/index.html
1
當前,您需要使用IFRAME SHIMS。希望這將改變一天。
看看這個頁面了一種通過使用iframe墊片爲例 http://earth-api-samples.googlecode.com/svn/trunk/demos/customcontrols/index.html
,並檢查了這等問題上的SO更多的一些信息 How can I place a html div over the Google Earth plugin? Involves wmode, I imagine
如果你有興趣,你可以看到我的網頁google earth http://www.3dwhistler.com/
相關問題
- 1. geckofx的Google地球插件
- 2. jQuery的上下文菜單插件
- 3. 而使用上下文菜單插件
- 4. 如何在上下文菜單中過濾菜單jquery插件
- 5. Google Chrome上下文菜單的
- 6. 適用於Android的Google地球插件
- 7. Google地球插件中的CSS
- 8. JavaScript擴展NPObject(Google地球插件API)
- 9. 點擊Google地球插件崩潰
- 10. AIR(FLEX)和Google地球插件API
- 11. 如果沒有Google地球插件,請加載「Google地圖」
- 12. Google地球插件:在單個.kmz中切換圖層?
- 13. jQuery - 左鍵單擊上下文菜單插件
- 14. 上下文菜單
- 15. 命名下拉菜單 - Google地圖
- 16. Jenkins插件下拉菜單
- 17. GTK:定位上下文菜單項w.r.t上下文菜單
- 18. Google地球或Google地圖?
- 19. 使用Superfish插件進行上下文菜單
- 20. 包資源管理器URI eclipse插件上下文菜單?
- 21. 用c#添加到office插件的上下文菜單#
- 22. Leopard操作系統的上下文菜單插件
- 23. 用於上下文菜單的jQuery插件
- 24. 如何爲Eclipse插件製作動態上下文菜單?
- 25. Google地球插件API - 如何獲取當前地圖比例?
- 26. 地鐵應用程序中的Google地球插件
- 27. C#上下文菜單延遲事件
- 28. 上下文菜單中的WinForm控件
- 29. 上下文菜單itemselect事件
- 30. 在Outlook 2010中有條件地添加上下文菜單項
我發現你回答之前使用這種技術,但你的回答是幾乎完全一樣我的實現。我沒有使用左側和頂部的'px',這是必要的嗎?感謝您的答覆弗雷澤! – goodwince 2012-04-03 20:43:56
好東西......是的,左邊和上邊的定義是「自動|長度|%|繼承」。明確添加長度單位是一個非常好的主意,因爲它消除了您是否想要像素或百分比的任何歧義。一些瀏覽器需要單位(FireFox),一些會默認爲像素(IE),其他的則會做其他事情。如果你打算像素,然後使用它們。 – Fraser 2012-04-08 15:42:18
Doh!你是對的!!我完全忘記了像素與百分比。這種簡單的事情很容易被人遺忘。再次感謝。 – goodwince 2012-04-08 19:56:26