On May 4, 2:19 am, Rossko <[email protected]> wrote:

>  Maybe the browser implements div size
> changes slowly - after all, it has to re-render the whole page twice
> as the height and width changes - and you should be looking to delay
> ANY API functions - the GScreenPoint calculations - until the browser
> has settled down.  That other marker-based example is triggering off
> the APIs own map resize event, which has got to be further along the
> chain.

// UNTESTED PSEUDO-CODE:

var resizeIterations = 0;
var resizeCount = 0;
var timer;

window.resize = function() {
   GEvent.trigger(map, "resizing");
};

GEvent.addListener(map, 'resizing', function() {
   resizeCount++;
   watchResize(deal_with_overlay);
};

function watchResize(fcn) {
  function doIt() {
   if (resizeIterations == resizeCount) {
    clearTimeout(timer);
    resizeIterations = 0;
    resizeCount = 0;
    fcn();
   } else {
    resizeIterations = resizeCount;
    timer = setTimeout(doIt, 500);
   }
 }
 if (resizeCount==1) timer = setTimeout(doIt, 500);
}

function deal_with_overlay() {
  // remove old overlay
  // re-place overlay
}

// That was UNTESTED PSEUDO-CODE

The idea is to count resize event calls and when the count stops
increasing, take the overlay actions. I think this does that.

The delay of 500 milliseconds might need to be longer, or it might
work fine shorter.

The listener is assigned to the map, but that's not necessary.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to