在GE的kml文件上使用Region时,不显示行标签

问题描述 投票:-1回答:2

我有一个基于Google Earth developer websitethis link提供的教程的kml文件。我的目标是绘制一条包含在一个区域内的线条(当我从中缩小时淡出)并且能够沿着线条轨迹显示标签名称。

enter image description here

而不是问号我想要这样的线的名称。

到目前为止,我已经实现了这行代码:

<?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" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<Document>
   <name>KmlFile</name>
   <Placemark>
      <name>SFO to LAX</name>
      <Style id="line_label">
      <LabelStyle>
         <scale>10</scale>
      </LabelStyle>
      <LineStyle>
          <color>ff00ffff</color>
          <width>5</width>
          <gx:labelVisibility>1</gx:labelVisibility>
      </LineStyle>
      </Style>
      <LineString>
         <tessellate>1</tessellate>
         <coordinates>
         -118.40897,33.943492,0 -122.383103,37.617112,0 
         </coordinates>
      </LineString>
      <Region> 
      <LatLonAltBox>
         <north>37.617112</north>
         <south>33.943492</south>
         <east>-118.40897</east> 
         <west>-122.383103</west> 
         <minAltitude>0</minAltitude>
         <maxAltitude>200000</maxAltitude>
         <altitudeMode>clampToGround</altitudeMode>
         </LatLonAltBox>
      <Lod>
         <minLodPixels>1024</minLodPixels>
         <minFadeExtent>1024</minFadeExtent>
      </Lod>
   </Region> 
</Placemark>
   <Placemark>
   <name>BOH to MAH</name>
   <Style id="line_label">
      <LabelStyle>
        <scale>1.3</scale>
      </LabelStyle>
      <LineStyle>
         <color>ff00ffff</color>
         <width>5</width>
         <gx:labelVisibility>1</gx:labelVisibility>
      </LineStyle>
   </Style>
   <LineString>
      <tessellate>1</tessellate>
      <coordinates>
      -117.40897,34.943492,0 -121.383103,38.617112,0 
   </coordinates>
   </LineString>
  </Placemark>
</Document>
</kml>

你能告诉我一个实现目标的方法吗?

google-maps line kml google-earth region
2个回答
1
投票

当功能变为活动状态时,显然将区域添加到地标不会在线型中正确启用labelVisibility mode。这是Google地球中的一个错误。 LabelVisibility仅在您不使用Region时才有效。

你可以通过在MultiGeometry中添加Point到地标来激活Region来解决这个问题。有一个点可以显示标签,标签显示在点的位置。

<Placemark>
      <name>SFO to LAX</name>
      <Style>
        <IconStyle>
            <Icon/>
        </IconStyle>
        <LabelStyle>
             <scale>1.3</scale>
        </LabelStyle>
        <LineStyle>
          <color>ff00ffff</color>
          <width>5</width>
          <gx:labelVisibility>1</gx:labelVisibility>            
        </LineStyle>
      </Style>

      <Region> 
       ...
      </Region> 

   <MultiGeometry>
     <Point>
         <coordinates>-119.884604,35.349412</coordinates>
     </Point>
     <LineString>
         <tessellate>1</tessellate>
         <coordinates>
         -118.40897,33.943492 -122.383103,37.617112
         </coordinates>
        </LineString>
    </MultiGeometry>   
</Placemark>

0
投票

解决方法是将Region放置在从地标到文件夹或文档的更高级别。效果很好。

© www.soinside.com 2019 - 2024. All rights reserved.