2012-04-05 19 views
1

私はGoogle Earth APIを使って遊んでいます。私は、相対的な3D視点から場所の間に線を引くのはすてきであると思った。私はGEのドキュメントを検索し、Googleの回答を検索しましたが、私に正しい道を導いたものは見つからなかったので、私はいくつかのコードを投稿し、おそらくいくつかの洞察を得ると思っていました。Google Earth API - 描画線が湾曲していますか?

次のコードは2つの場所をプロットし、それらの場所の間に線を描きます。残念ながら、描かれた線は地球をつなぎ合わせます。このように3Dで描いたときに地球の輪郭にラップさせる方法はありますか?私は線の高さの配置をさまざまなレベルで変えようとしましたが、線が場所を結ぶように見えないときの精度と全体的な視覚的魅力を犠牲にしています。

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

function initCB(instance) { 
    ge = instance; 
    ge.getWindow().setVisibility(true); 


    //---------------------------------PLACES 

    // Create the placemark. 
    var placemark = ge.createPlacemark(''); 
    placemark.setName("Location 1"); 

    // Set the placemark's location. 
    var point = ge.createPoint(''); 
    point.setLatitude(39.96028); 
    point.setLongitude(-82.979736); 
    placemark.setGeometry(point); 

    // Add the placemark to Earth. 
    ge.getFeatures().appendChild(placemark); 


    // Create the placemark. 
    var placemark2 = ge.createPlacemark(''); 
    placemark2.setName("Hop #2"); 

    // Set the placemark's location. 
    var point2 = ge.createPoint(''); 
    point2.setLatitude(25.7615); 
    point2.setLongitude(-80.2939); 
    placemark2.setGeometry(point2); 

    // Add the placemark to Earth. 
    ge.getFeatures().appendChild(placemark2); 

    //---------------------------------FOCUS 

    var lookAt = ge.createLookAt(''); 
    lookAt.setLatitude(39.96028); 
    lookAt.setLongitude(-82.979736); 
    lookAt.setRange(1000000.0); 
    lookAt.setAltitude(0); 
    lookAt.setTilt(45); 
    ge.getView().setAbstractView(lookAt); 


    //---------------------------------LINES 

    // Create the placemark 
    var lineStringPlacemark = ge.createPlacemark(''); 

    // Create the LineString 
    var lineString = ge.createLineString(''); 
    lineStringPlacemark.setGeometry(lineString); 

    // Add LineString points 
    lineString.getCoordinates().pushLatLngAlt(39.96028, -82.979736, 0); 
    lineString.getCoordinates().pushLatLngAlt(25.7615, -80.2939, 0); 
    //lineString.setAltitudeMode(ge.ALTITUDE_CLAMP_TO_GROUND); 
    //lineString.setAltitudeMode(ge.ALTITUDE_RELATIVE_TO_GROUND); 
    lineString.setAltitudeMode(ge.absolute); 

    // Create a style and set width and color of line 
    lineStringPlacemark.setStyleSelector(ge.createStyle('')); 
    var lineStyle = lineStringPlacemark.getStyleSelector().getLineStyle(); 
    lineStyle.setWidth(2); 
    lineStyle.getColor().set('9900ffff'); // aabbggrr format 

    // Add the feature to Earth 
    ge.getFeatures().appendChild(lineStringPlacemark); 

} 

function failureCB(errorCode) { 
} 

google.setOnLoadCallback(init); 

答えて

3

テッセレーションを設定し、必要に応じて、ラインストリング上にtrueを設定します。

は、APIの詳細

ためhttps://developers.google.com/kml/documentation/kmlreference#tessellatehttps://developers.google.com/kml/documentation/kmlreference#extrudeを参照してください、あなたの構文は

lineStringPlacemark.setTessellate(true); 
lineStringPlacemark.setExtrude(true); 

ようなものになるだろう。この上でいくつかの追加のAPIの例は、私が探していたものhttps://developers.google.com/earth/documentation/geometries

+0

見事であります。私が明らかにドキュメンテーションを見てきたことを私に指摘してくれてありがとう。 – TonyStark

関連する問題