2014-11-04 121 views
0

首先,我要感謝你在回答的努力。KML標籤<Camera>和<LookAt> - 不在谷歌地球插件工作

其次,我創建了一個包含谷歌地球的插件網站,我使用KML字符串來表示兩個座標。我想看看經度-122.084075,緯度37.4220033612141。 當我加載我的網站時,我沒有看到任何變化。

我的HTML代碼+的KML字符串:

<html> 
<head> 
<script type="text/javascript" src="https://www.google.com/jsapi"> </script> 
<script type="text/javascript"> 
    var ge; 
    google.load("earth", "1", {"other_params":"sensor=false"}); 

    function init() 
    { 
     google.earth.createInstance('map3d', initCB, failureCB);  
    } 

    function initCB(instance) 
    { 
     ge = instance; 
     ge.getWindow().setVisibility(true); 
     addKmlFromString(
          '<?xml version="1.0" encoding="UTF-8"?>' + 
          '<kml xmlns="http://earth.google.com/kml/2.0">' + 
          '<Document>' + 
          '<Placemark>' + 
          ' <name>Floating placemark</name>' + 
          '  <visibility>1</visibility>' + 
          '  <description>Floats a defined distance above the ground.</description>' + 
          ' <LookAt>' + 
          '  <longitude>-122.084075</longitude>' + 
          '  <latitude>37.4220033612141</latitude>' + 
          '  <altitude>45</altitude>' + 
          '  <heading>0</heading>' + 
          '  <tilt>90</tilt>' + 
          '  <range>100</range>' + 
          '  <altitudeMode>relativeToGround</altitudeMode>' + 
          ' </LookAt>' + 
          ' <Style>' + 
          ' <IconStyle>' + 
          '  <Icon>' + 
          '  <href>https://cdn1.iconfinder.com/data/icons/future/512/drones_watching-64.png</href> ' + 
          '  </Icon>' + 
          '  </IconStyle>' + 
          ' </Style>' + 
          ' <Point>' + 
          '  <altitudeMode>relativeToGround</altitudeMode>' + 
          '  <coordinates>-122.0822035425683,37.42228990140251,50</coordinates>' + 
          ' </Point>' + 
          '</Placemark>' + 
          ' <Placemark>' + 
          '  <name>Flight Line</name>' + 
          '  <visibility>1</visibility>' + 
          '  <description>Black line (10 pixels wide), height tracks terrain</description>' + 
          '  <styleUrl>#thickBlackLine</styleUrl>' + 
          '  <LineString>' + 
          '  <tessellate>1</tessellate>' + 
          '  <altitudeMode>relativeToGround</altitudeMode>' + 
          '  <coordinates>' + 
          '   -122.0822035425683,37.42228990140251,0' + 
          '   -122,37.8,0' + 
          '  </coordinates>' + 
          '  </LineString>' + 
          ' </Placemark>' + 
          '<Placemark><name>From</name><Point><coordinates>-122.0822035425683,37.42228990140251,0</coordinates></Point></Placemark>' + 
          '<Placemark><name>To</name><Point><coordinates>-122,37.8,0</coordinates></Point></Placemark>' + 
          '</Document>' + 
          '</kml>' 
         ); 
    } 

    function addKmlFromString(kmlString) 
     { 
      var kmlObject = ge.parseKml(kmlString); 

      ge.getFeatures().appendChild(kmlObject); 
     } 

     function failureCB(errorCode) 
     { 

     } 



     google.setOnLoadCallback(init); 
</script> 

</head> 
<body> 
<div id="map3d" style="height: 300px; width: 400px;"></div> 
</body> 
</html> 

請指導我。我究竟做錯了什麼? 非常感謝!

回答

0

我找到了答案就在這裏: https://developers.google.com/earth/documentation/camera_control#flytospeed

變焦相機

放大和縮小是由一系列屬性的注視,併爲攝像頭的高度屬性控制。

注意,改變注視的高度屬性改變點的高度被觀看。由於觀看者的範圍是相對於這一點的,所以觀衆的高度也會改變。

注視:

// Get the current view. 
var lookAt = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND); 

// Zoom out to twice the current range. 
lookAt.setRange(lookAt.getRange() * 2.0); 

// Update the view in Google Earth. 
ge.getView().setAbstractView(lookAt);