简体   繁体   English

Google地球如何顺利为KML地标设置动画

[英]Google Earth How to animate KML placemarks smoothly

I have some radar data to display with the Google Earth plugin. 我有一些雷达数据要与Google Earth插件一起显示。 Generally, it is some ground objects with coordinates and a timestamp. 通常,它是一些具有坐标和时间戳的地面对象。 I followed the instructions in https://developers.google.com/kml/documentation/time , tried both timestamp and timespan and it works fine. 我按照https://developers.google.com/kml/documentation/time中的说明进行操作,尝试同时使用时间戳和时间跨度,并且效果很好。 But the displaying effects are not satisfying. 但是显示效果并不令人满意。

For the timestamp solution, the placemarks just flash briefly at exactly the time indicated by "" tags. 对于时间戳解决方案,地标仅在“”标签指示的时间短暂闪烁。 And when I pressed play button, nothing shows up on the map. 当我按下播放按钮时,地图上没有任何显示。 Code sample: 代码示例:

<Folder>
  <name>Vehicles</name>
  <description>Timeline information of vehicles</description>
  <Placemark>
    <name>2</name>
    <description>(-84.114231,39.785436,-0.000216),V(13.411216,37.555181) at 0.00s</description>
    <TimeStamp>
      <when>2012-09-19T08:00:00Z</when>
    </TimeStamp>
    <styleUrl>#vehicleStyle</styleUrl>
    <Point>
      <coordinates>-84.114231,39.785436,-0.000216</coordinates>
    </Point>
  </Placemark>
  <Placemark>
    <name>910</name>
    <description>(-84.110335,39.788438,-0.000024),V(0.000000,0.000000) at 0.80s</description>
    <TimeStamp>
      <when>2012-09-19T08:00:30Z</when>
    </TimeStamp>
    <styleUrl>#vehicleStyle</styleUrl>
    <Point>
      <coordinates>-84.110335,39.788438,-0.000024</coordinates>
    </Point>
  </Placemark>
  <Placemark>
    <name>2</name>
    <description>(-84.114133,39.785494,-0.000285),V(13.411216,37.555118) at 0.80s</description>
    <TimeStamp>
      <when>2012-09-19T08:00:30Z</when>
    </TimeStamp>
    <styleUrl>#vehicleStyle</styleUrl>
    <Point>
      <coordinates>-84.114133,39.785494,-0.000285</coordinates>
    </Point>
  </Placemark>
  <Placemark>
    <name>910</name>
    <description>(-84.110307,39.788410,-0.000046),V(3.499966,307.390012) at 1.60s</description>
    <TimeStamp>
      <when>2012-09-19T08:01:00Z</when>
    </TimeStamp>
    <styleUrl>#vehicleStyle</styleUrl>
    <Point>
      <coordinates>-84.110307,39.788410,-0.000046</coordinates>
    </Point>
  </Placemark>
</Folder>
                ...

For the timespan case, the animation is OK but there is always a tail followed by each object: the placemarks in previous frames do not disappear immediately at the beginning of the new time span. 对于时间跨度情况,动画是可以的,但每个对象后面总是尾巴:前一帧中的地标不会在新的时间跨度开始时立即消失。

Code sample: 代码示例:

...
 <Folder>
  <name>Vehicles</name>
  <description>Timeline information of vehicles</description>
  <Placemark>
    <name>2</name>
    <description>(-84.114231,39.785436,-0.000216),V(13.411216,37.555181) at 0.00s</description>
    <TimeSpan>
      <begin>2012-09-19T08:00:00Z</begin>
      <end>2012-09-19T08:00:10Z</end>
    </TimeSpan>
    <styleUrl>#vehicleStyle</styleUrl>
    <Point>
      <coordinates>-84.114231,39.785436,-0.000216</coordinates>
    </Point>
  </Placemark>
  <Placemark>
    <name>910</name>
    <description>(-84.110335,39.788438,-0.000024),V(0.000000,0.000000) at 0.80s</description>
    <TimeSpan>
      <begin>2012-09-19T08:00:10Z</begin>
      <end>2012-09-19T08:00:20Z</end>
    </TimeSpan>
    <styleUrl>#vehicleStyle</styleUrl>
    <Point>
      <coordinates>-84.110335,39.788438,-0.000024</coordinates>
    </Point>
  </Placemark>
  <Placemark>
    <name>2</name>
    <description>(-84.114133,39.785494,-0.000285),V(13.411216,37.555118) at 0.80s</description>
    <TimeSpan>
      <begin>2012-09-19T08:00:10Z</begin>
      <end>2012-09-19T08:00:20Z</end>
    </TimeSpan>
    <styleUrl>#vehicleStyle</styleUrl>
    <Point>
      <coordinates>-84.114133,39.785494,-0.000285</coordinates>
    </Point>
  </Placemark>
  <Placemark>
    <name>910</name>
    <description>(-84.110307,39.788410,-0.000046),V(3.499966,307.390012) at 1.60s</description>
    <TimeSpan>
      <begin>2012-09-19T08:00:20Z</begin>
      <end>2012-09-19T08:00:30Z</end>
    </TimeSpan>
    <styleUrl>#vehicleStyle</styleUrl>
    <Point>
      <coordinates>-84.110307,39.788410,-0.000046</coordinates>
    </Point>
  </Placemark>
</Folder>
                ...

So is there any solution to make the placemarks animate continuously? 那么,有什么解决方案可以使地标连续进行动画处理吗? Thanks. 谢谢。

PS Track is not considered, because tracking information between data points are not available for now. 不考虑使用PS Track,因为数据点之间的跟踪信息目前不可用。

If I understand what you are asking then you could do this by simply toggling the style of the placemarks using the JavaScript api. 如果我了解您的要求,则可以通过使用JavaScript api切换地标的样式来实现。

To do this you could simply create a style in your Kml document such as. 为此,您可以简单地在Kml文档中创建样式,例如。

<Style id="vehicleStyleHighighted">
  <IconStyle>
     <color>ff00ff00</color>
     <colorMode>random</colorMode>
     <scale>1.5</scale>
     <Icon>
        <href>http://maps.google.com/mapfiles/kml/pal3/icon21.png</href>
     </Icon>
  </IconStyle>
</Style>

You can then use the method setStyleUrl() along with a timer to set each placemark's style. 然后,您可以将setStyleUrl()方法与计时器一起使用,以设置每个地标的样式。 IE You would toggle each placemarks style between #vehicleStyleHighighted and ' #vehicleStyleHighighted . IE,您可以在#vehicleStyleHighighted和' #vehicleStyleHighighted之间切换每个地标样式。

If you wanted more than a simple 'on/off' animation then you can define more than two animation states using this method and then simply apply them as required. 如果您想要的不仅仅是一个简单的“开/关”动画,则可以使用此方法定义两个以上的动画状态,然后根据需要简单地应用它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM