Is there a way of preventing a Google Maps (JS, v3) map being displayed from the get-go? I'm doing some pre-processing and would like to show my 'Loading' spinner until everything is good to go (more eloquently put, hide the map -- e.g. the container div
– until all pre-processing is complete – at which point, show the map).
Hooking up the map's idle
event doesn't help that much, since the map is already displayed when this event hits.
I know that the container div
gets inline-styled by GMaps after loading, my first idea was to clear out the style
attribute (whilst listening to the idle
event), but it would be interesting to see if there is a way of creating the map and not displaying it until all pre-processing is done.
Maybe by using an argument to the new google.maps.Map
constructor, or a MapOption
?
Any thoughts on this?
Thank you in advance!
This works for me. I'm using the JQuery library.
this works fine for me, I use jquery tabs
om this link https://code.google.com/p/gmaps-api-issues/issues/detail?id=1448
Also remember to call:
if you have changed the size of the
<div>
. Adisplay:none
<div>
has no size.Or you could just hide it like with css visablility or css opacity.
This will work
depending on what you are doing another posibility could be to have multiple bools you set to true when each process is done.
For example:
if you have a geocode service running which you want to wait for, you could have a var called GeoState
and in the result part of the geocoder set GeoState to true, then have a timed function check if all the services have returned true, when they have, make the map visible.