Google Earth web开发

google web插件开发

 

Google 地球插件及其 JavaScript API 使您可以将 Google 地图(一种真 3D 数字地球仪)嵌入到您的网页中。使用该 API 您可以绘制标记和折线、使图片覆盖区域、添加 3D 模型或加载 KML 文件,从而允许您构建复杂的 3D 地图应用程序。如果您有现有地图 API 站点,那么只需一行代码即可在您的网页上启用 3D 效果。

 

<html>
  <head>
    <title>Hello Google Earth!</title>
    <!-- *** Replace the key below below with your own API key, available at http://code.google.com/apis/maps/signup.html *** -->
    <script src="http://www.google.com/jsapi?key=ABCDEF";></script>
    <script>

google.load("earth", "1");

 

var ge = null;

 

function init() {

 resize();
  google.earth.createInstance("map3d", initCallback, failureCallback);
  var clientHeight = document.documentElement.clientHeight;
     document.getElementById("map3d_container").style.height=clientHeight+"px"; 
  }

 

function initCallback(object) {
   DS_ge.getWindow().setVisibility(true);
       DS_ge.getLayerRoot().enableLayerById(DS_ge.LAYER_BUILDINGS, true);  //显示建筑层
       DS_ge.getLayerRoot().enableLayerById(DS_ge.LAYER_BORDERS, true);   //线路层
       DS_geHelpers = new GEHelpers(DS_ge);
       oldSpeed=DS_ge.getOptions().getFlyToSpeed();

       DS_ge.getNavigationControl().setVisibility(DS_ge.VISIBILITY_AUTO);
    DS_ge.getOptions().setStatusBarVisibility(true);       //状态栏
    //DS_ge.getOptions().setOverviewMapVisibility(true);
  
    var navControl = DS_ge.getNavigationControl();
      navControl.setVisibility(DS_ge.VISIBILITY_SHOW);       //显示导航
        DS_ge.getOptions().setMouseNavigationEnabled(true);  //鼠标导航能用

    var la = DS_ge.createLookAt('');
       la.set(30,120,
              100, //高度
              DS_ge.ALTITUDE_RELATIVE_TO_GROUND,
              0, // heading
              0, // straight-down tilt
              50000 // range (inverse of zoom)
           );
       DS_ge.getView().setAbstractView(la);  定位到指定地点

}

 

function failureCallback(object) {

   alert("初始化失败");

}

function resize()
 {
      var clientHeight = document.documentElement.clientHeight;
  var clientWidth = document.documentElement.clientWidth;
   document.getElementById("map3d_container").style.height=clientHeight+"px";
   document.getElementById("map3d_container").style.width=clientWidth+"px";
 }


    </script>
  </head>
<body οnlοad="init();" id="body" onselectstart='return false' οncοntextmenu='return false' scroll='no' οnresize="resize()">
 <div id="map3d_container" style="border: 0px solid silver; height: 100%;" >
  <div id="map3d" style="height: 100%" ></div>
 </div>

  </body>

</html>


一个简单的三维显示成功了

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值