Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7781467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:14:10+00:00 2026-06-01T19:14:10+00:00

I am trying to draw a road incrementally as an animation over GE plugin.

  • 0

I am trying to draw a road incrementally as an animation over GE plugin. I have a set of coordinates (lat,long) in an array and I am using the following function in a loop at small time intervals to draw the entire road in small parts animatedly.

var intFeatureCounter4Trace=0  
  function createPath(lat1,lng1,lat2,lng2,strToolType){
        lineStringPlacemark = ge.createPlacemark('');
        var lineString = ge.createLineString('');
        lineStringPlacemark.setGeometry(lineString);
        lineString.setTessellate(true);
        lineString.getCoordinates().pushLatLngAlt(lat1,lng1,0);
        lineString.getCoordinates().pushLatLngAlt(lat2,lng2,0);
        lineStringPlacemark.setStyleSelector(ge.createStyle(''));
        var lineStyle=lineStringPlacemark.getStyleSelector().getLineStyle();
        lineStyle.setWidth(5);
        lineStyle.getColor().set("9900FFFF"); //'aabbggrr' format
        intFeatureCounter4Trace+=1;
        ge.getFeatures().appendChild(lineStringPlacemark);
    }

While drawing the road in small parts I am keeping track of the number of small line segments that are added to the GE plugin and use this feature count to remove all the added line segements in a loop using the following function :-

function clearPath(){
    for(var i=0;i<intFeatureCounter4Trace;i++){
       ge.getFeatures().removeChild(ge.getFeatures().getLastChild());
    }
}

The problem is for a large number of (lat,longs) say 20,000 or so, the clearPath() function hangs the browser and sometimes some features that are not to be removed are also removed. Is there a way to remove all the smaller segments in one go? i.e, Is there a way to append all smaller segments part by part (as animation) to a single feature and then remove it in one go from the GE plugin DOM instead of removing it part by part?

Regards,
Shiva

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T19:14:12+00:00Added an answer on June 1, 2026 at 7:14 pm

    There are a few ways to solve this.

    Firstly, using the existing code you have simply wrap any call to your clearPath method using the google.earth.executeBatch function. This should stop the hanging and execute the api calls much faster.

    google.earth.executeBatch(ge, clearPath);
    

    Secondly, you could simply write a cleaner clearPath function to remove all the features without the need for a global index.

    function clearPath() {
      var features = ge.getFeatures();
      while (features.getFirstChild()) {
        features.removeChild(features.getFirstChild());
      }
    }
    

    Thirdly, the way I would approach it, is to alter your createPath to simply create a single linestring placemark. Then I would create a amendPath method that will update the coordinate data for that placemark. Finally I would alter the clearPath method to simply call clear on the linestring coordinate array. You could also add a removePath method too if desired…

    Although it is written here and untested something along the following lines should work.

    var path = null; // global reference to the placemark we will create
    
    // set up the path placemark
    function createPath() {
      path = ge.createPlacemark('');
      path.setStyleSelector(ge.createStyle(''));
    
      var line = ge.createLineString('');
      line.setTessellate(true);
    
      var style = path.getStyleSelector().getLineStyle();
      style.setWidth(5);
      style.getColor().set("9900FFFF");
    
      path.setGeometry(line);
      ge.getFeatures().appendChild(path);
    }
    
    // update the path placemark's coordinate geometry
    function ammendPath(lat1,lng1,lat2,lng2) {
      var line = path.getGeometry();
      line.getCoordinates().pushLatLngAlt(lat1,lng1,0);
      line.getCoordinates().pushLatLngAlt(lat2,lng2,0);
      path.setGeometry(line);
    }
    
    // clear the path placemark's coordinate geometry 
    function clearPath() {
      path.getGeometry().getCoordinates().clear();
    }
    
    // remove the path placemark entirely (if required...)
    function removePath() {
      ge.getFeatures().removeChild(path);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When trying to draw the following quads in OpenGL using a vertex array (instead
I'm trying to draw over the whole screen by using the desktop canvas and
I am trying to draw an animation. To do so I have extended View
I'm trying to draw a line using ctx.lineTo in loop. I have small function
I am trying to draw a series of rectangles using OpenGL but some of
I am trying to draw a textured cube using just 8 vertices and one
I am trying to draw a circle using Windows Form at runtime inside a
I'am trying to draw a line above mapkit. If I try to set the
basically i am trying to draw the path i.e road path. for that i
I am trying to draw a very long line with a Path. The line

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.