Issue:
I have a dialog page in a jQuery Mobile document which contains a small Google map to show a location. I want to load the map before loading the dialog page. As in:
$("#dialogPage").bind("pagebeforeshow", function() {
initializeSmallMap();
});
However, Google Maps works incorrectly whenever the div
the map is contained in is has a display
proprety of none (see Google Maps Display:None Problem). And since this function is executed before the page is actually loaded, the containing div
naturally has a display
property of none.
Now, obviously, there's a simple solution to this. All I need to do is initialize the map after the page has been shown, which makes the div
have a display property of block:
$("#dialogPage").bind("pageshow", function() {
initializeSmallMap();
});
However, since the dialog has already been loaded, there is an annoying, noticeable flicker when the map appears.
Question:
How do I get rid of the described flicker?
Possible Solutions:
div
containing the map have a display
property of block before the dialog is loaded. If I wasn't using jQuery Mobile, it would be simple and painless to implement this effect while still hiding the map until needed:
position: absolute;
left: -10000px;
display: block;
However, since jQuery Mobile automatically overrides page styles, I don't know how I could get this to work.
div
containing the map. I Googled this option and had no luck, but considering my terrible Googling skills, I would not be completely surprised if this was actually possible.