【问题标题】:Turning off country borders via the KML通过 KML 关闭国家/地区边界
【发布时间】:2012-05-08 17:02:08
【问题描述】:

Google 地球默认设置为“边框和标签”(即显示国家/地区轮廓)。我有想要关闭边框的 KMZ/KML 文件。我搜索了描述 KML 的文档,但找不到与图层相关的任何内容。

我也试过在打开和不打开边框的情况下保存 KMZ 文件,它们是相同的。

有人知道如何通过 KML API 访问图层吗?

【问题讨论】:

    标签: kml google-earth google-earth-plugin


    【解决方案1】:

    您还不能直接通过 KML 在 Google 地球中打开/关闭图层。目前这是由 Google 地球用户手动完成的操作。

    但是,目前有一个指令可以打开/关闭历史图像、街景和阳光模式。 https://developers.google.com/kml/documentation/kmlreference#gxvieweroptions

    但您可以通过 GE API 轻松打开/关闭图层:

    启用特定层:

      ge.getLayerRoot().enableLayerById(ge.LAYER_NAME, true)
    

    禁用图层:

      ge.getLayerRoot().enableLayerById(ge.LAYER_NAME, false);
    

    参考:https://developers.google.com/earth/documentation/layers#layers

    【讨论】:

      【解决方案2】:

      API 没有为 ge.LAYER_BORDERS 中的各个层定义常量,但是如果您查看 KML 文件,每个“文件夹”节点都有一个 ID,因此,正如 JasonM1 所说,您可以为每个层使用 enableLayerById您想要关闭,已打开顶部包含节点(在本例中为 ge.LAYER_BORDERS)。

      这是我用来通过 API 清理“边框和标签”层的代码:

      ge.getLayerRoot().enableLayerById(ge.LAYER_BORDERS, true);
      ge.getLayerRoot().enableLayerById("530286de-c7b3-11dc-938c-dd553d8c9902", false);       // internation borders
      ge.getLayerRoot().enableLayerById("cfdff130-394a-11e0-98fa-dd5743f1dfd8", false);       // coastline
      ge.getLayerRoot().enableLayerById("533444c6-c7b3-11dc-b02e-dd553d8c9902", false);       // 1st level borders too
      ge.getLayerRoot().enableLayerById("534ab67a-c7b3-11dc-a2a7-dd553d8c9902", false);       // 2nd level borders too
      ge.getLayerRoot().enableLayerById("e2334aaa-e853-11df-9192-77880e18aa7d", false);       // geographic features
      

      附言我现在似乎无法找到“borders and labels.kml”文件的位置,但它可能就在某个地方,将继续寻找......

      【讨论】:

        猜你喜欢
        • 2016-05-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-03-14
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多