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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:35:32+00:00 2026-05-16T08:35:32+00:00

I am using Google Maps API v3 on a website I am developing. I

  • 0

I am using Google Maps API v3 on a website I am developing. I have a drop-down box beneath my map which allows the user to switch between different sets of markers to be displayed on the map. Each marker is displayed using marker.setMap().

My problem is that the map sometimes takes a long time to display the new markers, especially in IE. I want to show a “Loading” animation while the map is switching markers. But I don’t know how to detect when the map has finished displaying the new data (there is no page load, since this is all AJAX). Is there a callback or event listener for a setMap() event, so I can call a function to stop the “Loading” animation when the last marker has finished loading?

  • 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-05-16T08:35:34+00:00Added an answer on May 16, 2026 at 8:35 am

    There doesn’t seem to be a callback or event listener for setMap(), but I figured out a way to accomplish what I wanted. I am loading the Google Map using jQuery. Here is my code.

    When initializing the map, I set up a listener for the ‘idle’ event, which hides the “loading” animation. The ‘idle’ event is triggered whenever the map is finished redrawing after a scroll or zoom change:

    google.maps.event.addListener(this.map, 'idle', function() {
     $('#loading').hide();
    });
    

    And in my function to clear overlays, I first show the loading animation, then clear each marker using setMap(null). Then I very slightly recenter the map by changing the longitude by .000000001. This happens after all the setMap() calls, and triggers the ‘idle’ event which hides the loading animation.

    // clear overlays from the map
    function clearOverlays() {
     $('#loading').show();
    
     // clear the markers from the active data array
     if (activeData) {
      for (i in activeData) { activeData[i].setMap(null); }
     }
     activeData = '';
    
     // very slightly recenter the map to trigger the 'idle' event
     var centerlat = MYMAP.map.getCenter().lat();
     var centerlng = MYMAP.map.getCenter().lng() + .000000001;
     recenter = new google.maps.LatLng(centerlat, centerlng);
     MYMAP.map.setCenter(recenter);
    }
    

    It is a bit of a hack, but I hope someone else finds this useful.

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

Sidebar

Related Questions

I'm using google maps api to have a map show up on my website
I have the following problem. I have embedded a map using Google Maps' API.
I have a website using the Google-maps Javascript API V3. I would like to
I'm using the Google Maps API (v3) on my website to show a map
I am using the Google Maps api on my website and I have been
I am using a google map with the full maps api on my website.
I'm using Google Maps API v2 and Geoxml to produce a map which is
I am using Google Maps API 3. I have a map and a button.
We have an existing website which currently uses v2 of the google maps api
Using Google Maps API v3 I have a map with the countries coloured using

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.