【问题标题】:Using the Google earth API how do I stop the placemark label from having an animation when I update it's position?使用 Google 地球 API 如何在更新位置时阻止地标标签显示动画?
【发布时间】:2014-04-01 13:34:57
【问题描述】:

我正在绘制带有标签的地标,然后我会持续更新它,每秒一次。地标图标本身没有动画,但附加的标签有。该图标会立即出现,并且在删除旧图标并添加新图标时,没有动画。然而,地标标签在文本淡入视图的位置绘制时有一点动画。每次我删除旧地标并添加新地标时,我都会得到这个动画。如何停止动画?

// Create the placemark.
var placemark = ge.createPlacemark('');
placemark.setName(object1['Designation']);

// Define a custom icon.
var icon = ge.createIcon('');
icon.setHref('http://maps.google.com/mapfiles/kml/paddle/red-circle.png');
var style = ge.createStyle(''); //create a new style
style.getIconStyle().setIcon(icon); //apply the icon to the style
placemark.setStyleSelector(style); //apply the style to the placemark

// Set the placemark's location.  
var point = ge.createPoint('');
point.setLatitude(12.345);
point.setLongitude(54.321);
placemark.setGeometry(point);

// Add the placemark to Earth.
ge.getFeatures().appendChild(placemark);

【问题讨论】:

    标签: google-maps google-maps-api-3 kml google-earth-plugin


    【解决方案1】:

    要关闭此行为,请调用 GEOptions.setFadeInOutEnabled()。例如

    ge.getOptions().setFadeInOutEnabled(false);

    见:https://developers.google.com/earth/documentation/options#new_feature_animation

    编辑

    添加和删除地标的方式有点奇怪。

    “每次我删除旧地标并添加新地标时,我都会得到这个 动画”

    做你想做的更好的方法不是删除和添加地标 - 它是更新单个地标上的标签。

    在您的示例中,您只需每秒调用一次placemark.setName(whatever)。 所有其他代码只需调用一次即可初始化/配置地标。

    【讨论】:

    • 谢谢 - 但由于某种原因,它对我不起作用。我将该行放在“ge.getWindow().setVisibility(true);”上方正如我在另一个示例中发现的那样,但它仍在用动画绘制名称。 :|
    • 是的,我计划更新代码以更新地标,而不是不断地删除和添加它们。我会检查您的建议并很快回来查看。
    猜你喜欢
    • 2012-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-09
    • 1970-01-01
    • 1970-01-01
    • 2018-04-17
    相关资源
    最近更新 更多