1

よく読んで解決策を見つけようとしましたが失敗しました...

geoxmlv3の指示に従いました:http ://code.google.com/p/geoxml3/wiki/Usage

ここにその文書からの引用があります:

  <script type="text/javascript">
    var myParser = new geoXML3.parser({afterParse: useTheData});
    myParser.parse('my_geodata.kml');

    function useTheData(doc) {
      // Geodata handling goes here, using JSON properties of the doc object
      for (var i = 0; i < doc.placemarks.length; i++) {
        doSomething;
      }
    };
  </script>

ドキュメントによると、doc.placemarksは機能し、KMLファイル内のプレースマークのjsonの配列を返すはずですが、残念ながら、この「doc」は存在しません(未定義)、何か考えはありますか?

4

2 に答える 2

2

polyブランチを使用している場合、「doc」は配列です。

function useTheData(doc) {
  // Geodata handling goes here, using JSON properties of the doc object
  for (var i = 0; i < doc[0].placemarks.length; i++) {
    doSomething;
  }
};

ドキュメントの例を修正します。

実例

于 2012-12-26T12:49:52.953 に答える
0

Google Maps API v3のKmlLayerを使ってみませんか?KMLファイルの情報を地図に簡単にマッピングできます。

https://developers.google.com/maps/documentation/javascript/layers#KMLLayers

于 2012-12-26T04:03:35.980 に答える