笔记地球

来源:互联网 发布:哪里的域名不需要备案 编辑:程序博客网 时间:2024/04/28 18:31
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <script src="http://www.google.com/jsapi?key=" type="text/javascript"></script>
    <script type="text/javascript">
    var ge;
    
    var placemark;
    var dragInfo = null;
    
    google.load("earth", "1");
    
     function GetRequest()  //获取上一页传的值
{  
var url = location.search; //获取url中"?"符后的字串  
var theRequest = new Object();  
if(url.indexOf("?") != -1)  
{  
  var str = url.substr(1);  
    strs = str.split("&");  
  for(var i = 0; i < strs.length; i ++)  
    {  
     theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);  
    }  
}  
return theRequest;  
}  
    
    
    function init() {
      google.earth.createInstance('map3d', initCallback, failureCallback);
    }
    
    function initCallback(instance) {
      ge = instance;
      ge.getWindow().setVisibility(true);
    
      ge.getNavigationControl().setVisibility(ge.VISIBILITY_AUTO);


      ge.getLayerRoot().enableLayerById(ge.LAYER_BORDERS, true);
      ge.getLayerRoot().enableLayerById(ge.LAYER_ROADS, true);
    
      
      placemark = ge.createPlacemark('');
   
    
    var Request=new Object();  
    Request=GetRequest();  
    var place;  
   place=Request['place'];  
  X=Request['X'];   
   Y=Request['Y'];  
    
    
      var point = ge.createPoint('');
      point.setLatitude(X);
      point.setLongitude(Y);
      placemark.setGeometry(point);
    
      // add the placemark to the earth DOM
      ge.getFeatures().appendChild(placemark);
    
      // look at the placemark we created
      var la = ge.createLookAt('');
      la.set(41.753432, 123.430560,
        0, // altitude
        ge.ALTITUDE_RELATIVE_TO_GROUND,
        0, // heading
        0, // straight-down tilt
        18000 // range (inverse of zoom)
        );
      ge.getView().setAbstractView(la);
      placemark.setName(place);
    
      // listen for mousedown on the window (look specifically for point placemarks)
      google.earth.addEventListener(ge.getWindow(), 'mousedown', function(event) {
        if (event.getTarget().getType() == 'KmlPlacemark' &&
            event.getTarget().getGeometry().getType() == 'KmlPoint') {
          //event.preventDefault();
          var placemark = event.getTarget();
    
          dragInfo = {
            placemark: event.getTarget(),
            dragged: false
          };
        }
      });
    
      // listen for mousemove on the globe
      google.earth.addEventListener(ge.getGlobe(), 'mousemove', function(event) {
        if (dragInfo) {
          event.preventDefault();
          var point = dragInfo.placemark.getGeometry();
          point.setLatitude(event.getLatitude());
          point.setLongitude(event.getLongitude());
          dragInfo.dragged = true;
        }
      });
    
      // listen for mouseup on the window
      google.earth.addEventListener(ge.getWindow(), 'mouseup', function(event) {
        if (dragInfo) {
          if (dragInfo.dragged) {
            // if the placemark was dragged, prevent balloons from popping up
            event.preventDefault();
          }
    
          dragInfo = null;
        }
      });
    
      
    }
    
    function failureCallback(errorCode) {
    }
    
    </script>
  </head>
  <body onload="init()" style="font-family: arial, sans-serif; font-size: 13px; border: 0;">
    <div id="map3d" style="width: 500px; height: 380px;"></div>
  </body>

</html>




原创粉丝点击