【问题标题】:KML IconStyle color entered as blue but displays red in Google EarthKML IconStyle 颜色输入为蓝色,但在 Google 地球中显示为红色
【发布时间】:2019-08-25 04:09:31
【问题描述】:

我使用十六进制颜色来标记图标。对于蓝色,我使用0000ff。在 KML 文件中,它是 <color>ff0000ff</color>。但是,在 Google 地球中打开 KML 时,地标图标是红色的。

看看https://developers.google.com/kml/documentation/kmlreference,我认为颜色应该编码为ff + hexadecimal number,因此黑色表示为ff000000,这有效,但ff0000ff蓝色无效。

我尝试了各种样式和图标选项,但均未成功。我已经阅读并看到了如何合并图标和颜色的分层效果。似乎使用 wht-blank.png 将是一个中性画布来应用颜色,但我怀疑它可能会干扰。

下面是我的测试kml。

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">
    <Document>
        <name>kml_test</name>
        <Placemark>
            <name>uniq_name</name>
            <Style>
                <IconStyle>
                    <scale>1</scale>
                    <color>ff0000ff</color>
                    <Icon>
                        <href>http://maps.google.com/mapfiles/kml/paddle/wht-blank.png</href>
                    </Icon>
                </IconStyle>
            </Style>
            <LabelStyle>
                <color>ffffffff</color>
                <scale>0.6</scale>
            </LabelStyle>
            <LookAt>
                <longitude>-118.000000</longitude>
                <latitude>34.000000</latitude>
                <range>1000</range>
            </LookAt>
            <Point>
                <altitudeMode>clampToGround</altitudeMode>
                <extrude>0</extrude>
                <coordinates>-118.000000,34.000000,0</coordinates>
            </Point>
        </Placemark>
    </Document>
</kml>

我希望&lt;color&gt;ff0000ff&lt;/color&gt; 在 Google 地球中打开 kml 时显示蓝色图标,而不是红色。

【问题讨论】:

    标签: kml google-earth kmz


    【解决方案1】:

    KML 不使用正常的颜色顺序,而是以蓝色、绿色、红色或:AABBGGRR 的相反顺序,其中 AA 是 alpha 或透明度,BB 是蓝色,GG 是绿色,RR 是红色。

    有关更多信息,请参阅&lt;color&gt; 标签的文档,此处: https://developers.google.com/kml/documentation/kmlreference#elements-specific-to-colorstyle

    特别是这一行:

    The order of expression is aabbggrr
    

    对于您要使用的蓝色图标:&lt;color&gt;ffff0000&lt;/color&gt;

    【讨论】:

    • 文档没有意义,但您的回答澄清了。十六进制为 R-G-B,需要将 KML 模式翻转为 B-G-R。完美!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-09-19
    • 1970-01-01
    • 2013-02-05
    • 2011-12-03
    • 1970-01-01
    • 2011-10-28
    • 1970-01-01
    相关资源
    最近更新 更多