0

我正在尝试为 GE 插件中的点设置动画。问题是,每次我更改最终冻结插件的底层几何图形时,它似乎都会重新渲染自己。

var lineString = ge.createLineString(''),
    placemark  = ge.createPlacemark(''),
    coords     = lineString.getCoordinates(),
    features   = ge.getFeatures();

placemark.setGeometry(lineString);
features.appendChild(placemark);

myPoints.forEach(function(point) {
  // google earth re-renders on every one of these calls
  coords.pushLatLngAlt(point.lat, point.lng, 0);
});

// I want something explicit, like this, instead
placemark.redraw();

它不是将所有更改应用于 LineString 坐标,然后在地标上调用重新渲染方法,而是每次都重新渲染。

我的第一个想法是做某种类型的双缓冲。但是我加载了很多点,我无法承受双倍的内存使用量。

有什么解决方法吗?

编辑:

我尝试删除几何图形,对其进行编辑,然后将其添加回来。地标刚刚闪过……:/

placemark.setGeometry(null);

myPoints.forEach(function(point) {
  coords.pushLatLngAlt(point.lat, point.lng, 0);
});

placemark.setGeometry(lineString);

编辑:

通过使用google.earth.executeBatch,我确实设法显着提高了速度

google.earth.executeBatch(ge, function() {
  myPoints.forEach(function(point) {
    coords.pushLatLngAlt(point.lat, point.lng, 0);
  });
});
4

1 回答 1

2

一些想法:

我看到你编辑了你的问题,说你找到了 executeBatch 函数,这有帮助。您必须在每次迭代期间推送很多点才能看到插件挂起。

于 2012-11-07T18:18:01.920 回答