日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

google earth 中有關浮動層的添加問題

系統 2112 0

最近項目需要google earth有關的技術點,遇見了要在google earth上面添加浮動層的問題。怎么設置z-index也沒發使得元素在earth上面顯示,總是被壓下去。

補充:google map沒有此類問題,設z-index就可以控制浮動層的位置。

查了好多資料,才發現也有其他人遇見。好像是google earth固有的“缺陷”。

解決辦法:

利用動態生成iframe講圖片添加進去并設置z-index。iframe-shim-for-google-earth

經典代碼階段:

    //本地的html按鈕
function createNativeHTMLButton(x, y, width, height,id) {
  // 創建浮動層
  var button = document.createElement("div");
  button.className="nxte";
  button.id=id;
  var ahref = document.createElement('a');
  ahref.href = '#';
  button.appendChild(ahref);
  
  // create an IFRAME shim for the button
  var iframeShim = document.createElement('iframe');
  iframeShim.frameBorder = 0;
  iframeShim.id=id+"Iframe";
  iframeShim.scrolling = 'no';
  iframeShim.src = (navigator.userAgent.indexOf('MSIE 6') >= 0) ?
      '' : 'javascript:void(0);';

  // position the button and IFRAME shim
  var pluginRect = getElementRect(document.getElementById('earth'));
  button.style.position = iframeShim.style.position = 'absolute';
  button.style.left = iframeShim.style.left = (pluginRect.left + x) + 'px';
  button.style.top = iframeShim.style.top = (pluginRect.top + y) + 'px';
  button.style.width = iframeShim.style.width = width + 'px';
  button.style.height = iframeShim.style.height = height + 'px';
  // set up z-orders
  button.style.zIndex = 10;
  iframeShim.style.zIndex = button.style.zIndex - 1;
  
  document.body.appendChild(button);
  document.body.appendChild(iframeShim);
 
}

/**
 * Helper function to get the rectangle for the given HTML element.
 */
function getElementRect(element) {
  var left = element.offsetLeft;
  var top = element.offsetTop;
  
  var p = element.offsetParent;
  while (p && p != document.body.parentNode) {
    if (isFinite(p.offsetLeft) && isFinite(p.offsetTop)) {
      left += p.offsetLeft;
      top += p.offsetTop;
    }
    
    p = p.offsetParent;
  }
  
  return { left: left, top: top,
           width: element.offsetWidth, height: element.offsetHeight };
}

  
引用:createNativeHTMLButton(left, top, 14, 49,"nxte");

一個很好的demo: http://lineandpixel.com/blog/iframe-shim-for-google-earth

google earth 中有關浮動層的添加問題

google earth 中有關浮動層的添加問題


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 阜宁县| 德清县| 中山市| 海原县| 永定县| 合川市| 淳化县| 山阳县| 济源市| 含山县| 黄石市| 乌苏市| 栾川县| 双江| 贵溪市| 囊谦县| 伊金霍洛旗| 镇赉县| 南充市| 鄯善县| 屏边| 凉城县| 洛阳市| 宿州市| 文安县| 遂溪县| 巫山县| 昂仁县| 惠水县| 延边| 丹寨县| 明溪县| 珲春市| 嘉荫县| 榆社县| 西安市| 宁阳县| 东光县| 凤山县| 呼伦贝尔市| 平谷区|