jquery problem with google map
-
well this is not exactly the problem of this theme, but I hope I can get a solution from experts out there.
So I’m using a plugin Mappress to show google maps on my post. like this: http://www.indiavirtualinfo.com/shimla/
Now if you notice, the map is visible when it’s normally posted, but not visible when it’s shown under the tab. I tried a couple of faq etc, and got to know this:
This is an issue with the Google Maps API. Maps do not display properly when they are inside an element that is initially hidden, such as a hidden tab, slider, accordion, etc. MapPress includes a workaround for jQuery UI Tabs. For other libraries or controls, youβll need to implement your own solution using Javascript.
with a solution something like this:
When a hidden element is displayed, you can redraw the map by calling its resize() method. For example to redraw the first map on the screen use:
mapp0.resize();This example redraws maps inside elements with class βmycontrolβ when the element is clicked. Note that set Timeout is only needed if there is an animation (such as sliding into place) that must complete before the map is resized:
jQuery(document).ready(function() { jQuery('.mycontrol').on('click', function() { jQuery(this).find('.mapp-canvas').each(function() { var id = jQuery(this).attr('id'); var map = window[id]; setTimeout(function() { map.resize(); }, 350); }); }); });But I don’t know where to place this code and how.
Any help would be highly appreciated.
The topic ‘jquery problem with google map’ is closed to new replies.
