kml - 使用KML在 map 上显示名称

标签 kml google-earth

我可以使用KML显示多边形,圆形等。
现在,我只想使用KML显示一些名称。这可能吗 ?

最佳答案

如果要禁止(通过KML)在Google Earth的 map 上显示地标标签,则可以将比例尺0的LabelStyle添加到地标中(请参见下面的示例中的sn_hide样式)。如果您想在 map 上隐藏标签名称,直到将鼠标悬停在图标上,那么StyleMaps是您最好的选择。

以下示例中的第一个地标的名称显示在“位置”面板中,但使用LabelStyle从 map 中隐藏了。第二个地标#2使用StyleMap来隐藏标签,直到用户突出显示或将鼠标悬停在该图标上,该图标才会激活显示标签的突出显示样式。第三个地标#3使用始终显示标签的默认样式。

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
    <Document>
        <name>Hide and show labels</name>
        <Style id="sn_hide">
            <LabelStyle>
                <scale>0</scale>
            </LabelStyle>
        </Style>
        <Style id="sh_style">
            <LabelStyle>
                <scale>1.1</scale>
            </LabelStyle>
        </Style>
        <StyleMap id="msn_hide">
            <Pair>
                <key>normal</key>
                <styleUrl>#sn_hide</styleUrl>
            </Pair>
            <Pair>
                <key>highlight</key>
                <styleUrl>#sh_style</styleUrl>
            </Pair>
        </StyleMap>

        <Placemark>
            <name>Placemark 1</name>
            <description>Label name always hidden</description>
            <styleUrl>#sn_hide</styleUrl>
            <Point>
                <coordinates>-119.232195,36.016021</coordinates>
            </Point>
        </Placemark>

        <Placemark>
            <name>Placemark 2</name>
            <description>Hover over place to show label</description>
            <styleUrl>#msn_hide</styleUrl>
            <Point>
                <coordinates>-119.2324,36.0155</coordinates>
            </Point>
        </Placemark>

        <Placemark>
            <name>Placemark 3</name>
            <description>Always showing</description>
            <Point>
                <coordinates>-119.232672,36.014837</coordinates>
            </Point>
        </Placemark>
    </Document>
</kml>

关于kml - 使用KML在 map 上显示名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13378030/

相关文章:

javascript - Leaflet.Draw - geoJSON 到 Kml

url - Google 地球 KML - href 片段 URL 在 # 处被截断 - 无法在浏览器中打开

javascript - 在 Google 地球 API : Changing view with radio buttons 中

google-earth - 将透明 DIV 放置在 Google 地球顶部

ios - 如何从 iOS 应用程序打开 Google 地球中的 KMZ 文件

postgresql - 检查postgis多边形数据的有效性(从shapefile导入)

google-maps - 融合表KML导入

google-maps - 谷歌地图引擎 : export kml curl

xml - Google 地球 KML 解析错误

c# - 在 Google Earth API KML 文件中搜索字符串值地标?