如果您想要禁止在Google地球地图上显示地标标签(通过KML),那么您可以将LabelStyle添加到具有0比例的地标(请参阅下面的示例中的sn_hide样式).如果您想要在地图上停留标签名称,直到将鼠标悬停在图标上,那么StyleMaps是您最好的选择.
下面示例中的第一个地标的名称显示在"地点"面板中,但使用LabelStyle隐藏在地图中.第二个地标#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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
19908 次 |
| 最近记录: |