Google web 加载自己发布的kml数据

官网实例http://code.google.com/apis/ajax/playground/?exp=earth#hello,_earth

APi查看http://code.google.com/intl/zh-CN/apis/earth/documentation/reference/index.html

//加载kml文件
function addKML(url) {

//DS_ge为整个web控件对象

    google.earth.fetchKml(DS_ge,url,function(kmlObject)
 {
  /**
  if (!kmlObject) {
        // show error
          setTimeout(function() {
             alert('Error loading KML.');
           }, 0);
          return;
        }

  else
  {
       DS_ge.getFeatures().appendChild(kmlObject);
       
 });
 
}

url为数据发布的路径

 

在初始化成功initCallback函数里加入addKML(url)

function initCallback(object) {

  DS_ge = object;
  tools= new Tools();
       DS_ge.getWindow().setVisibility(true);
//这里发布的数据是geoserver发布的wms数据,也可以说kml文件
  addKML("http://192.168.0.33:8080/geoserver/wms/kml?layers=nci:ORA_GIS_TRANS_LINE");

 addKML("http://192.168.0.33:8080/test/pt.kml");

       var la = DS_ge.createLookAt('');
       la.set(defaultview.lat,defaultview.lng,
              defaultview.altitude, //高度
              DS_ge.ALTITUDE_RELATIVE_TO_GROUND,
              0, // heading
              0, // straight-down tilt
              50000 // range (inverse of zoom)
           );
       DS_ge.getView().setAbstractView(la);
  tool_operate("0","select");
  addToolbar();
  changeMapToOverviewMap();
     createNativeHTMLButton(locationx-hawkeyeIframe_width, locationy-hawkeyeIframe_heigt, hawkeyeIframe_width,hawkeyeIframe_heigt); // x, y, width, height
 }

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值