Mariusz Pilarczyk
Mariusz Pilarczyk

Reputation: 518

Event on tiles start loading in Google Maps v3

I am looking for a way to detect if tiles of google maps v3 are loading or and event which triggers when tiles start loading.

My UI is build as follows:

There is a map on background layer. On the foreground there is a form in which user enters location. After he hits enter, map is panning and zooming to specified location.

All I want to do is hide foreground layer AFTER: 1. Map is zoomed 2. Map is panned 3. All tiles are loaded

The problem is that when typed location is very close to starting location, there is no "tilesloaded" event triggered because map panned only few pixels. So I can't depend on "tilesloaded" event.

I can't also depend on "bounds_changed" or "idle" event because they trigger BEFORE all tiles loads.

Do you have any ideas ?

Upvotes: 1

Views: 1013

Answers (1)

Dr.Molle
Dr.Molle

Reputation: 117314

You may:

  1. listen for the tilesloaded-event and hide the form when it fires
  2. to catch the case where tilesloaded didn't fire store the bounds(when opening the form) in a variable. Observe the bounds_changed -event and check if the difference(in screen-pixels) between the northeast/southwest of the stored bounds and the current bounds is less than 256(that's the size of a tile). When it does you may assume that there are no tiles to load, trigger the tilesloaded-event immediately.

Upvotes: 2

Related Questions