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 8224095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:56:19+00:00 2026-06-07T14:56:19+00:00

Thanks for reading this … I’ve been searching and experimenting for 3 days trying

  • 0

Thanks for reading this …

I’ve been searching and experimenting for 3 days trying to solve a pretty basic javascript issue.

I’m creating a Google map with 45 markers. The markers:

  • are clustered using the MarkerClusterer utility
  • can be clicked to open an infowindow (each one displays a different image)
  • all “drop” nicely into place when the page loads.

So far so good.

The problem is applying a “setTimeout” function to drop the markers sequentially (instead of all at once). I’ve tried a dozen variations, nothing works.

I’m a total novice, any help would be hugely appreciated!

You can view a simplified version of the map at:

http://www.domatchaworld.com/googlemap6.html

Here is the code:

var locations = [  
[39.11009, -120.03169, '<img width="300" height="239" src="images/img01.jpg" style="margin:5px;"/>'],
[37.77493, -122.41942, '<img width="300" height="239" src="images/img02.jpg" style="margin:5px;"/>'],
[48.85320, 2.30206, '<img width="300" height="239" src="images/img03.jpg" style="margin:5px;"/>'],
[48.77734, -121.81320, '<img width="300" height="239" src="images/img04.jpg" style="margin:5px;"/>'],
[49.35365, -123.26187, '<img width="300" height="239" src="images/img45.jpg" style="margin:5px;"/>']
]; 

var map;
var markers = [];
var mc; 
var mcOptions = {
  gridSize: 20,
  maxZoom: 15
};

map = new google.maps.Map(document.getElementById("map_canvas"), {
zoom: 3,
center: new google.maps.LatLng(31.65338, -40.42969),
mapTypeId: google.maps.MapTypeId.TERRAIN
});

mc = new MarkerClusterer(map, [], mcOptions);

var infowindow = new google.maps.InfoWindow();

google.maps.event.addListener(map, 'click', function() {
infowindow.close();
});

var marker;
var i;

for (i = 0; i < locations.length; i++) {  
    marker = new google.maps.Marker({
    position: new google.maps.LatLng(locations[i][0], locations[i][1]),
    animation: google.maps.Animation.DROP,
    map: map
  });

  google.maps.event.addListener(marker, 'click', (function(marker, i) {
    return function() {
      infowindow.setContent(locations[i][2]);
      infowindow.open(map, marker);
    }
  })(marker, i));

mc.addMarkers(markers, true);

markers.push(marker); //push local var marker into global array

}
  • 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-07T14:56:24+00:00Added an answer on June 7, 2026 at 2:56 pm

    Instead of adding all markers to the MarkerClusterer at once, create your array of markers, then animate them (I’ve copy pasted your code and added comments at the end…):

    var locations = [
        [39.11009, - 120.03169, '<img width="300" height="239" src="images/img01.jpg" style="margin:5px;"/>'],
        [37.77493, - 122.41942, '<img width="300" height="239" src="images/img02.jpg" style="margin:5px;"/>'],
        [48.85320, 2.30206, '<img width="300" height="239" src="images/img03.jpg" style="margin:5px;"/>'],
        [48.77734, - 121.81320, '<img width="300" height="239" src="images/img04.jpg" style="margin:5px;"/>'],
        [49.35365, - 123.26187, '<img width="300" height="239" src="images/img45.jpg" style="margin:5px;"/>']
    ];
    
    var map;
    var markers = [];
    var mc;
    var mcOptions = {
        gridSize: 20,
        maxZoom: 15
    };
    
    map = new google.maps.Map(document.getElementById("map_canvas"), {
        zoom: 3,
        center: new google.maps.LatLng(31.65338, - 40.42969),
        mapTypeId: google.maps.MapTypeId.TERRAIN
    });
    
    mc = new MarkerClusterer(map, [], mcOptions);
    
    var infowindow = new google.maps.InfoWindow();
    
    google.maps.event.addListener(map, 'click', function () {
        infowindow.close();
    });
    
    var marker;
    var i;
    
    for (i = 0; i < locations.length; i++) {
        marker = new google.maps.Marker({
            position: new google.maps.LatLng(locations[i][0], locations[i][1]),
            animation: google.maps.Animation.DROP,
            map: map
        });
    
        google.maps.event.addListener(marker, 'click', (function (marker, i) {
            return function () {
                infowindow.setContent(locations[i][2]);
                infowindow.open(map, marker);
            }
        })(marker, i));
    
        //don't add to cluster yet
        //mc.addMarkers(markers, true);
    
        markers.push(marker); //push local var marker into global array
    
    }
    
    // now animate and add to cluster
    (function animateNextMarker() {
      if (markers.length > 0) {
        mc.addMarker(markers.pop(), true);
        setTimeout(animateNextMarker, 250);
      }
    })();
    

    Hope this helps 🙂

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

Sidebar

Related Questions

Hi and thanks for reading this. I am trying to use the IF EXISTS/IF
Thanks for reading this. I imagine this is really a javascript question, and my
Thanks for reading this one =) I'm trying to figure out how to figure
Hi thanks for reading this! Please help me. I am trying to create a
Thanks for reading this. I have no idea why this is throwing a NullReferenceException
Firs of all thanks for reading this. I'm having trouble updating the progress from
Thanks in Advance for reading and answer this question. I got button in asp
thanks for your reading. I am trying to modify Jquery Nivo Zoom plugin to
Thanks for reading this. I have 2 MySQL databases - master for writes, slave
Thanks for reading this. I am dynamically generating some data which includes a select

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.