Hey APh, here´s what I´ve found:
if you call getBounds() from withing the initialize function, nothing
is returned (possibly because no map has been initialized?).
Even if you set you <body>´s onlick like this
onClick='initialize(); get_me_bounds();'
where get_me_bounds() is a function that calls getBounds(), undefined
is returned, but one out of a hundred times, it returns bounds!
So I tried this:
onClick='initialize(); setTimeout('get_me_bounds()', 100);'
which delays the call for get_me_bounds() 100 miliseconds, and IT
WORKS!
I think the API is not yet done processing the map construct, so you
have to give it a breath to finish up.
Let me know if this is too crazy.
On Nov 9, 2:05 am, APh <
gis_n_...@yahoo.com> wrote:
> Hi String and ALL!
> My inline call of initialize() is the LAST operator before </body> tag
> and I hope that this is equal to
> string <body onLoad="initialize()">. It was my experiment...
> BUT I'm try both variants! Result is the same -getBounds() don't
> work.
> It was yesterday...
>
> Today I make <body onLoad="initialize()"> version andgetBounds()
> WORK!!!
> Without any special efforts!
> Later 10 min. don't work again. Now work... Paradox!
> It so unstable!
>
> Situation described above is for Chrome. IE8 show message thatgetBounds() is not defined as before.
>
> I think that there can be initialize() has a certain magic value. And
> all resources become accessible already after completion of this
> function.
> When I have taken out my business logic (alert("Center...") and alert
> ("Bounds...") ;) for limits of a body of function initialize(), all
> began to work remarkably!
>
> Thx to all!
> R.,
> Alex Philippov
>
> On 8 ноя, 14:43, String <
sterling.ud...@googlemail.com> wrote:
>
>
>
> > It's almost definitely a timing issue.
>
> > My first guess is that at the point where you callgetBounds(), the
> > page is not yet fully rendered, so the map doesn't know what its
> > bounds are going to be yet. This is because you're calling your
> > initialize function inline, rather than attaching it to the body's
> > onload event, or otherwise waiting until the page is done loading.
>
> > I'd also suspect that, since v3 doesn't load resources until it needs
> > them,getBounds() may not be able to be called so soon after