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 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

Ask A Question

Stats

  • Questions 491k
  • Answers 491k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Yes, you have to make it yourself. If your modal… May 16, 2026 at 10:16 am
  • Editorial Team
    Editorial Team added an answer html.css is default stylesheet of firefox. you can find more… May 16, 2026 at 10:16 am
  • Editorial Team
    Editorial Team added an answer Have you tried Nokogiri (Railscasts video)? Actually Ryan Bates has… May 16, 2026 at 10:16 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

We have an existing website which currently uses v2 of the google maps api
Is it possible to do a google map lookup using the google maps API
I am displaying a map on a website using the Google Map API. I
I have a question regarding map api. I was using the the google map
I am using http://code.google.com/apis/maps/documentation/geocoding/ api from google to get geolocation based on address. I
I am trying to extent a website page that displays google maps with the
I'm implementing a Google Map on a website. One requirement is to display a
I have a controller (address /Home/Test see below) which definately responds to get request
I'm trying to generate a Google Map based off of results from a database.
I got a static map link using this wizard http://gmaps-samples.googlecode.com/svn/trunk/simplewizard/makestaticmap.html and the marker is

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.