2012-04-30 15 views
0

私はKMLファイルを作成しました。これを自分のウェブサイトのGoogle Earth APIに表示したいと考えています。私はGoogle code playgroundウェブサイトのKMLファイルをGoogle Earth APIに解析する方法は?

を閲覧しましたが、KMLをGoogle Earth APIに解析する必要があるかどうかはわかりません。これは私が作成したKMLファイルのリンクです:http://g.co/maps/6zp5a

誰でも助けてくれますか?

答えて

1

代わりにfetchKmlを使用する必要があります。

http://maps.google.com/maps/ms?msid=201182140457027399871.0004bee0c7348bce68977&msa=0&ll=9.438,39.5105&spn=130.55749,316.054688&output=kml最後に「KML = &出力を」あなたはまた、有効なURLを提供する必要があり、その代わりに、あなたの「短い」、URLの、あなたは完全なものを使用する必要があり、追加

http://code.google.com/apis/ajax/playground/?exp=earth#fetch_good_kml

サンプル・コードのページへのURLとそれを実行プットが、それは以下

+0

ありがとうございます。私はそれを試しましたが、点のいずれも表示されません。あなたはそれを実行するときにAPIの色の点を見ましたか?また、別のKML(インタラクティブ)をフェッチすることもあります。私はボックスに上記のURLを入力しようとしましたが、うまくいきません。 –

+0

通常のフェッチと対話的なフェッチの両方の例に、私があなたに与えたURLを(最後に&output = kmlを付けて)入れます。どちらも私のために目印を読み込みます。ビューを手動で移動して参照できるようにする必要がありますが、コーディングが増えると、独自のカスタムビューをロードして設定することができます。 – lifeIsGood

1

に動作しますが、あなたのKMLのフェッチ機能付きの「Hello地球」のデモです。青いパドルを利用するには、あなたのkmlのアイコンをスタイルする必要があります。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html> 
    <meta http-equiv="content-type" content="text/html; charset=utf-8" /> 
    <head> 
<!-- 
Copyright 2008 Google Inc. 
Licensed under the Apache License, Version 2.0 (the "License"); 
you may not use this file except in compliance with the License. 
You may obtain a copy of the License at 

    http://www.apache.org/licenses/LICENSE-2.0 

Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
See the License for the specific language governing permissions and 
limitations under the License. 
--> 
    <title>Hello Google Earth!</title> 
    <script src="http://www.google.com/jsapi"></script> 
    <script> 
google.load("earth", "1"); 

var ge = null; 

function init() { 
    google.earth.createInstance("map3d", initCallback, failureCallback); 
} 

function initCallback(object) { 
    ge = object; 
    ge.getWindow().setVisibility(true); 
    function finished(object) { 
    if (!object) { 
     // wrap alerts in API callbacks and event handlers 
     // in a setTimeout to prevent deadlock in some browsers 
     setTimeout(function() { 
     alert('Bad or null KML.'); 
     }, 0); 
     return; 
    } 
    ge.getFeatures().appendChild(object); 
    } 
    // fetch the KML 
    var url = 'http://maps.google.com/maps/ms?ie=UTF8&authuser=0&msa=0&output=kml&msid=201182140457027399871.0004bee0c7348bce68977'; 
    google.earth.fetchKml(ge, url, finished); 

    document.getElementById('installed-plugin-version').innerHTML = 
    ge.getPluginVersion().toString(); 
} 

function failureCallback(errorCode) { 
} 
    </script> 
    </head> 
    <body onload='init()' id='body'> 
    <center> 
     <div> 
     Hello, Earth! 
     </div> 
     <div id='map3d' align="left" style='border: 1px solid silver; height: 600px; width: 800px;'></div> 
    </center> 
    </body> 
</html> 
+0

ありがとうございました!ピンポイントが表示されますが、円は表示されません。 –

+0

ここに青いパドルが付いた作り直しされたkmlです。このURLに置き換えるだけでよい(http://maps.google.com/maps/ms?ie=UTF8&authuser=0&msa=0&output=kml&msid=201784530892227263374.0004bf65bb9e0a92e227d) – jwilliams