I have a Google Map that is created using the newer Google Maps API V3 from a Perl script. The script builds the map from values passed to it from hidden form fields in the parent page, and returns the map into an iframe in the same parent pa开发者_如何转开发ge.
The reason that the map is in the iframe, is because I have discovered browser issues both with Firefox and IE when trying to render the map directly to a div on the parent page. This does not occur when the map is elsewise rendered into the iframe window. I have concluded that this is because the new Google Maps API V3 is a bit querky in how it interprets CSS inheiritence, and more or less demands that the map be rendered to a block element with 100% values for both width and height. By rendering the iframe window into the div, I can control the size I want through the div's CSS, while at the same time giving the Google Maps API the 100% width and height values through the iframe document.
This came about originally, because I really wanted the map to be rendered in a hidden div, that is made visible with jQuery when a user clicks on the Map link. However, this will not work in either Firefox or IE, and the map fails to render in an element whose initial CSS display property is set to none. This will not even work when trying it with an outer div wrapper where it should have inheirited the values from that wrapper div.
So now I have a workaround, where the div is not initially hidden, the iframe shows, the maps builds perfectly, and then a setTimeout event written into the iframe page then closes the div to hide the map on the parent page. I know, I know, it's quite the hack, but it does allow the map to render properly and then hides it from view.
So what I am looking for here, is a way to tell when the map has finished rendering to initiate the jQuery event to hide the div, instead of the setTimeout method that is currently being used (which is also no guarentee that the map really has finished rendering. It's only a good timed guess at best).
I have searched through the Google Maps API V3 documentation, and looked around elsewhere on the web to see if there was some way to tell when the map has completed rendering without success, and am hoping someone familiar with the new Google Maps API might have the answer I seek to at least make this workaround hack a bit more graceful :)
Thanks for any direction you can point me to achieve what I'm trying to accomplish here.
How about moving the iframe just off screen using absolute positioning then you don't need to hide it ...
Btw, I have not seen any of the problems you describe in my work with V3, so maybe they are just side effects from other problems in your code.
As far as I know, there is no way, since the browser doesn't expose this functionality through JavaScript.
If you just want to know if tile images have loaded, listen for the tilesloaded
event.
精彩评论