Using jQuery to construct and update the contents for a Google Maps API custom control overlay, Google Maps sometimes does not draw the updated contents.
Main.overlay = $('<div><div style="background:white"><div id="overlay"></div></div></div>').detach();
Main.map.controls[google.maps.ControlPosition.TOP_LEFT].push(Main.overlay[0]);
...
$('#overlay').html('New content');
Resizing the map by resizing the window will cause the new content to display. Mousing over the new content, the cursor changes as if the new content were there. I tried
google.maps.event.trigger(Main.map, 'resize');
to trigger a redraw, but since the map has not actually changed size, I'm guessing that is optimized away.
How can I tell Google Maps to force a redraw? Or is there something about the jQuery .html() function that might be causing this?
This problem occurs on Safari 7.0.2 (9537.74.9) on Mac OS X 10.9 and on the iPhone simulator, but does not occur on Firefox, Chrome, or on and iOS 6 iPad 2.
Inspecting the DOM shows that the changes are being made as desired, they are just not being displayed. Following suggestions at Force DOM redraw/refresh on Chrome/Mac adding
$('#overlay').hide().show(0);
works around what appears to be a Webkit bug.