覆盖浏览器中显示的谷歌地图上的多个KML文件

时间:2011-04-11 03:39:35

标签: file kml

需要了解在浏览器中显示的单个Google地图上叠加多个KML文件的过程。用于此目的的KML文件可以指向不同的位置。例如:北美的KML1&亚洲KML2。任何人都可以帮助我。

2 个答案:

答案 0 :(得分:1)

我认为你正在寻找这个:

http://code.google.com/apis/kml/documentation/kml_tut.html#network_links

示例:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
  <Folder>
    <name>Network Links</name>
    <visibility>0</visibility>
    <open>0</open>
    <description>Network link example 1</description>
    <NetworkLink>
      <name>Random Placemark</name>
      <visibility>0</visibility>
      <open>0</open>
      <description>A simple server-side script that generates a new random
        placemark on each call</description>
      <refreshVisibility>0</refreshVisibility>
      <flyToView>0</flyToView>
      <Link>
        <href>http://yourserver.com/map1.kml</href>
      </Link>
    </NetworkLink>

    <NetworkLink>
      <name>Random Placemark</name>
      <visibility>0</visibility>
      <open>0</open>
      <description>A simple server-side script that generates a new random
        placemark on each call</description>
      <refreshVisibility>0</refreshVisibility>
      <flyToView>0</flyToView>
      <Link>
        <href>http://yourserver.com/map2.kml</href>
      </Link>
    </NetworkLink>
  </Folder>
</kml>

答案 1 :(得分:0)

您可以使用Google Maps JS API执行此操作。您需要为每个KML文件创建带有google.maps.KmlLayer的叠加层。

请参阅此示例:http://code.google.com/apis/maps/documentation/javascript/examples/layer-kml.html

API文档: http://code.google.com/apis/maps/documentation/javascript/overlays.html#KMLLayers