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

  • Home
  • SEARCH
  • 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 9092097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:45:38+00:00 2026-06-16T22:45:38+00:00

I need to add a 1 second delay between each plot of my markers.

  • 0

I need to add a 1 second delay between each plot of my markers. I came up with the following code but cannot make it work. Any idea ?

var latlng = new google.maps.LatLng(43,2.34);
var myOptions = {
  zoom: 7,
  center: latlng,
  mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

for ( var i=0, len=json.length; i<len; i++ ){
  obj = json[i];

  // Get lat / long and put them on the map
  var lat = obj.latitude;
  var long = obj.longitude;

  display_marker(map, lat, long);
}

display_marker = function(map, lat, long){
  setTimeout(function(){}, 1000);
  var marker = new google.maps.Marker({
    map: map,
    position: new google.maps.LatLng(lat,long),
    title: "Latitude: " +  lat + "\nLongitude: " + long,
  });
}
  • 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-16T22:45:39+00:00Added an answer on June 16, 2026 at 10:45 pm

    there a 2 things going wrong right here.

    the first one is, that you use the setTimeout with an empty function. your code needs to be inside that function:

    display_marker = function(map, lat, long){
      setTimeout(function() {
        var marker = new google.maps.Marker({
          map: map,
          position: new google.maps.LatLng(lat,long),
          title: "Latitude: " +  lat + "\nLongitude: " + long,
        });
      }, 1000);
    }
    

    the second on is, that your loop triggers the display_marker one after the other, so if you fix problem 1, even then you all your markers will be generated after ~1000ms

    an easy way to fix this, is to pass the current value if your increment-var to your display marker, and multiply it for your setTimeout:

    var obj, lat, long;
    for ( var i=0, len=json.length; i<len; i++ ){
      obj = json[i];
    
      // Get lat / long and put them on the map
      lat = obj.latitude;
      long = obj.longitude;
    
      display_marker(map, lat, long, i);
    }
    
    display_marker = function(map, lat, long, increment){
      setTimeout(function() {
        var marker = new google.maps.Marker({
          map: map,
          position: new google.maps.LatLng(lat,long),
          title: "Latitude: " +  lat + "\nLongitude: " + long,
        });
      }, increment * 1000);
    }
    

    hint: see what i did with the variable declarations. you were redeclaring the variables inside your loop

    hint2: my code is untested, but it should give you the right idea how to solve your problem

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in C# forms I need code to add a second form to my existing.
I have a vector of values I need to add to a second vector
I need to manually page a GridView based report, i.e. add a second page
I need to add a second DataTable from our app's main DataSet into a
The issue I'm having is that I need to add a second stylesheet to
I may be asking the wrong question, but what I need is to add
In order to perform some animations I need to add a second image, identical
I need add Auto complete on apex Tabular Form. there is a column as
I need add a new user group for mediawiki. The new group has more
I can't access a element with its href. Like this example, i need add

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.