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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:09:56+00:00 2026-05-25T14:09:56+00:00

I’m working with the Google Maps v3 API, and I have a custom overlay

  • 0

I’m working with the Google Maps v3 API, and I have a custom overlay layer based on the ImageMapType class. I would like to show a loading indicator of some sort while the overlay’s tiles are loading, but I don’t see any way to know when they are finished.

The code to create the overlay looks similar to the following:

var myOverlay = new google.maps.ImageMapType({
    getTileUrl: myGetTileUrl,
    tileSize: new google.maps.Size(256, 256),
    isPng: true
});

myMap.overlayMapTypes.push(myOverlay);

The above works just fine, and the overlay successfully loads; it just seems that no events are emitted by the map to indicate anything about the ImageMapType overlay’s status.

I would expect the map to at least emit an “idle” event when the tiles are finished loading, but as far as I can tell it does not.

How may I know when the ImageMapType overlay is finished loading?

EDIT

I wrote a test case on jsFiddle: http://jsfiddle.net/6yvcB/ — Watch your console output for the word “idled” to see when the idle event fires. Notice that it never fires when you click the button to add an overlay.

Also, kittens.

  • 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-25T14:09:56+00:00Added an answer on May 25, 2026 at 2:09 pm

    It would seem there’s no “out of the box” way to know when an ImageMapType overlay has finished loading, but thanks to a suggestion from Martin over on the Google Maps API v3 Forums I was able to add in my own custom event that is emitted when the layer finishes loading.

    The basic approach is:

    • Every time a URL is requested, add the URL to a list of pending URLs
    • Override ImageMapType.getTile() so that we can add “onload” event listeners to each <img> element.
    • When each image’s “load” event fires, remove that image from the list of pending URLs.
    • When the list of pending URLs is empty, then emit our custom “overlay-idle” event.

    I’ve copied the code below for posterity, but you can see it in action on jsFiddle: http://jsfiddle.net/6yvcB/22/

    // Create a base map
    var options = {
        zoom: 3,
        center: new google.maps.LatLng(37.59, -99.13),
        mapTypeId: "terrain"
    };
    var map = new google.maps.Map($("#map")[0], options);
    
    // Listen for the map to emit "idle" events
    google.maps.event.addListener(map, "idle", function(){
        console.log("map is idle");
    });
    
    // Keep track of pending tile requests
    var pendingUrls = [];
    
    $("#btn").click(function() {
        var index = 0;   
        var urls = [ "http://placekitten.com/256/256", 
                     "http://placekitten.com/g/256/256",
                     "http://placekitten.com/255/255", 
                     "http://placekitten.com/g/255/255",
                     "http://placekitten.com/257/257", 
                     "http://placekitten.com/g/257/257" ];
    
        var overlay = new google.maps.ImageMapType({
            getTileUrl: function() { 
                var url = urls[index % urls.length];
                index++;
    
                // Add this url to our list of pending urls
                pendingUrls.push(url);
    
                // if this is our first pending tile, signal that we just became busy
                if (pendingUrls.length === 1) {
                     $(overlay).trigger("overlay-busy");   
                }
    
                return url; 
            },
            tileSize: new google.maps.Size(256, 256),
            isPng: true,
            opacity: 0.60
        });
    
        // Listen for our custom events
        $(overlay).bind("overlay-idle", function() {
            console.log("overlay is idle"); 
        });
    
        $(overlay).bind("overlay-busy", function() {
            console.log("overlay is busy"); 
        });
    
    
        // Copy the original getTile function so we can override it, 
        // but still make use of the original function
        overlay.baseGetTile = overlay.getTile;
    
        // Override getTile so we may add event listeners to know when the images load
        overlay.getTile = function(tileCoord, zoom, ownerDocument) {
    
            // Get the DOM node generated by the out-of-the-box ImageMapType
            var node = overlay.baseGetTile(tileCoord, zoom, ownerDocument);
    
            // Listen for any images within the node to finish loading
            $("img", node).one("load", function() {
    
                // Remove the image from our list of pending urls
                var index = $.inArray(this.__src__, pendingUrls);
                pendingUrls.splice(index, 1);
    
                // If the pending url list is empty, emit an event to 
                // indicate that the tiles are finished loading
                if (pendingUrls.length === 0) {
                    $(overlay).trigger("overlay-idle");
                }
            });
    
            return node;
        };
    
        map.overlayMapTypes.push(overlay);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to count the length of a string with PHP. The string
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace

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.