Using the Google earth API how do I stop the placemark label from having an animation when I update it's position?

StackOverflow https://stackoverflow.com/questions/22097037

سؤال

I am drawing a placemark with a label and then I update it continually, once a second. The placemark icon itself does not have an animation, but the label attached to it does. The icon just appears instantly and as the old one is removed and the new one added, no animation. However the placemark label has a little animation when it's drawn where the text fades into view. Every time I delete the old placemark and add the new one I get this animation. How do I stop the animation?

// 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);
هل كانت مفيدة؟

المحلول

To turn off this behavior call GEOptions.setFadeInOutEnabled(). e.g.

ge.getOptions().setFadeInOutEnabled(false);

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

Edit

The way you are adding and removing the placemarks smells a bit funky.

"Every time I delete the old placemark and add the new one I get this animation"

A much better way to do what you want is not to delete and add placemarks - it is to update the label on a single placemark.

In your example you need to simply call placemark.setName(whatever) every second. All the other code only needs be called once to initialize/configure the placemark.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top