首先,我要感謝你在回答的努力。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>
請指導我。我究竟做錯了什麼? 非常感謝!
謝謝,但我用我寫到這裏的答案。 – 2015-03-24 12:24:33