Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have a module which generates two google map blocks. First map is always displayed properly, but second is always corrupted.
I have to anyhow change the browser window(de-maximize, maximize, resize,...) to dispaly second map as it shoul be displayed. I played with it a little bit and I found that it's caused by the quicktabs module itself. I have ajax turned off, because nothing would display with it enabled, so I assume that the bug is somewhere in the qt "skeleton".
Screenshot -> http://img142.imageshack.us/img142/5403/screenshot002cf3.png
Comment | File | Size | Author |
---|---|---|---|
#48 | quicktabs_gmap_fix.zip | 4.07 KB | nkschaefer |
#47 | quicktabs_gmap_fix.zip | 3.27 KB | nkschaefer |
#11 | quicktabs-352247-11.patch | 1.08 KB | marshmn |
#10 | quicktabs-352247-10.patch | 1.06 KB | marshmn |
#3 | gmap&qtabs.png | 49.83 KB | Pasqualle |
Comments
Comment #1
PasqualleIs it your own module? can you share some minimal code to display a google map?
My first guess would be that the javascript used to resize the map background to the size of the available area does not work on hidden HTML elements, as the second tab is hidden at page load.
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous commented"raw" code :)
Comment #3
PasqualleOk, I can reproduce this bug. I used the gmap module where I put a map into a node, and displayed that node in two tabs..
The problem is that the bounding box for the goggle map is wrongly calculated for the second tabpage. The google map displayed on any page is a collection of small images. Only images which intersects with the bounding box should be displayed on the page.
On the attached picture the quicktab with red border should be the bounding box. The problem is that the gmap uses something different. With firebug I highlighted one gmap image (a box with light blue background), this image should not be there as it is outside the bounding box.
So the problem is with position. We need this box to be the same as the tabpage, but I don't know what is causing this. Could be a simple css issue, or a position bug in gmap javascript..
Interesting note: If I launch firebug when the second tabpage is open then that map starts to work correctly and the problem flips to the first tabpage.
Comment #4
PasqualleComment #5
Heather51 CreditAttribution: Heather51 commentedAny solution to this problem yet? Im having the same issue with gmaps and tabs. Maps which load properly if accessed via their node url, do not fully load when accessed as part of a quicktabs block. If I launch firebug the map loads as expected. I can then click various tabs on the page and when I return to the map it is loaded ok but if I leave the quicktab page completely, when I return the map does not load properly again.
Comment #6
atelier CreditAttribution: atelier commentedI am also having an issue with this. Any progress toward getting this resolved would be appreciated.
Comment #7
esplinter CreditAttribution: esplinter commentedsame problem here using quicktabs 6.x-2.0-rc3
Comment #8
marshmn CreditAttribution: marshmn commentedNote that the title of this issue is a little mis-leading. I don't believe that the issue is with 2 gmaps, it's actually any gmap which is not displayed on the first tab.
If I display a gmap on the first tab then it works fine. On any other tab then it's broken.
I think this may be something to do with the gmap being initialized when it's container is hidden.
I saw a fix for a similar issue, in a different context, was to have the container positioned off screen rather than actually hiding it. I don't know if a similar technique would be possible here or whether it would work.
Matt
Comment #9
Pasquallefrom http://docs.jquery.com/UI/Tabs
there are 2 solutions described on that page..
Comment #10
marshmn CreditAttribution: marshmn commentedFollowing on from Pasqualle's response above I have looked into this a little further. The two solutions suggested are:
I looked at using resizeMap() and I think that in some cases that might solve the problem of corruption, but it didn't solve one of my problems which was the incorrect centering of the map.
The technique given for hiding non-active tabs by rendering them off-screen does seem to work, though I wasn't able to make it work just by using CSS. Instead I have made a patch which changes quicktabs to use this technique and attaching the patch to this post. The patch has been made against the latest dev release version 6.x-2.x-dev as of 2009-06-16 and can be applied from the quicktabs module folder by: patch -p0 < /path/quicktabs-352247-10.patch
The patch fixes both problems that I've seen with this - corruption in the map and incorrect centering of the map, both of which occur when a map is placed on a tab other than the first tab. The patch works by removing the original behavior of using hide() and show() on the tabs to hide/show them. Instead, when javascript is enabled then tabs to be hidden have a CSS class 'quicktabs-hide' added to them and when active that class is removed. Some CSS code is added for that class which positions the element in question off-screen.
I've tested that the fix works on both IE and Firefox and that tabs continue to work when javascript is disabled.
I think this change still needs quite a bit of testing though as this is quite a fundamental change to the way things work so I'm a bit worried it may not work with some browser or conditions.
Hope it helps and please get in touch with me if more info on the patch is required.
Comment #11
marshmn CreditAttribution: marshmn commentedDuring some further testing of the above patch I noticed that, in some cases (maybe all), there was an extra margin added at the bottom of the page. I've made a change to the CSS that was added so that the positioning is set off-screen both to the left and above the page which seems to fix it. This patch replaces the one above, you only need to apply this patch on it's own to the dev release.
Comment #12
PasqualleI do not believe that the module should change the hiding method. But you can change it now (without hacking the module) with simply adding the following css selector to your theme's css file:
http://drupal.org/cvs?commit=239028
this needs documentation..
Comment #13
eddowding CreditAttribution: eddowding commentedI'm using the dev version and trying to load a gmap to a tab via ajax. Not too surprisingly it's not working, saying "javascript is required to view this map".
I'm falling back to load all at once for now, but if you can think of a nice fix, it'd be welcome when you get a moment.
Lovely work so far -- I was told about qt yesterday and it's making things a LOT better already. Thank you!
Comment #14
Pasqualle@eddowding: #345175: what could be inside ajax quicktabs
Comment #15
srobert72 CreditAttribution: srobert72 commentedWith QuickTabs 6.x-2.x-dev (2009-Jul-18) I still have the problem.
I have only one GMap but it works correctly only if it is in first tab.
Does this release should fixe this issue ?
Comment #16
Pasqualle@srobert72: did you make the changes described in comment #12?
Comment #17
srobert72 CreditAttribution: srobert72 commentedYes I use default theme Garland.
I wrote CSS fix at the end of
/drupal/themes/garland/style.css
.I flushed all caches.
With FireBug in FireFox I can see CSS fix is in use :
HTML :
CSS :
Comment #18
farald CreditAttribution: farald commentedSubscribing
Comment #19
Mree CreditAttribution: Mree commentedI am also having an issue with this by 6.x-2.0-rc3.
And I found an solution :
(quicktabs.css)
Change from
div.quicktabs_tabpage.nojs-hide {
display: none;
}
To
div.quicktabs_tabpage.nojs-hide {
display: block;
}
and now looks ok.
I'm not sure is this change will cause any other issue.
Just for refer.
Comment #20
Pasqualle@Mree: I am sure that change will cause other issues. For example try to disable javascript in your browser..
Comment #21
kvvnn CreditAttribution: kvvnn commented#41 and #47 here - http://drupal.org/node/315236 - should be helpful to anyone looking to fix the Gmap Ajax bug
Comment #22
held69 CreditAttribution: held69 commentedI am Having an issue with this as well, using the module conditional fields combined with location.
http://drupal.org/node/730084
The javascript solution could be working for me as well, however i dont know how to implement this in to conditional fields.
some help much appreciated.
Thanks
Comment #23
Pasqualle@Mree: nojs-hide was removed in rc4. the correct solution for rc4 is in comment #12
@held69: if I understand correctly you are using the conditional fields module to display a gmap. So you need to find the place where the module hides and shows a field. search for: hide() and show() in the js files. Then replace it with addClass('something-hide') and removeClass('something-hide'), and create the corresponding css. You should check the commit linked in comment #12 to see what was changed in QT.
Comment #24
held69 CreditAttribution: held69 commented@pascalle,
thanks for your reply.
In this file i have tried some adjustments but got syntax errors as a result.
Is it possible for you to specify the point where the .addClass(field-hide) and the .removeClass(field-hide)mentioned under twelve should be placed?
thanks
Comment #25
Pasqualle@held69: please add your comment to the Conditional Fields issue, and try to create a patch (or code suggestions), which can be reviewed with the module maintainer and others. I would like to fix QT issues here..
my last comment on this here is: you need to change all lines starting with
showOrHide == 'show'
, and you will probably lose the fade in/out effect option..Comment #26
held69 CreditAttribution: held69 commentedSorry,
i'll continue my thread here:
http://drupal.org/node/730084
Thanks
Comment #27
EvanDonovan CreditAttribution: EvanDonovan commentedThe .quicktabs-hide code given in #12 did not work, since the tab was still display: none; I believe. I had to use:
That worked.
Comment #28
EvanDonovan CreditAttribution: EvanDonovan commentedWhat should be done so this "task" can be wrapped up? Where should the documentation go? Can it be submitted as a patch, or is it just for the Drupal handbook?
Should my CSS be tested further first? And, if so, should the status on this be set to "needs review"?
Comment #29
EvanDonovan CreditAttribution: EvanDonovan commentedComment #30
Pasqualleyes, please create a d.o handbook page if you have the time for it
and any help is welcome on other documentation issues also
http://drupal.org/project/issues/quicktabs?component=Documentation
also if someone creates an Advanced help module style help for these kind of issues, then it might be added to the module..
Comment #31
soncco CreditAttribution: soncco commentedI've used the code on http://drupal.org/node/131034#comment-532642, but my problem persist. To fix it I've changed code:
And I've used with :
It works for me, but maybe I need suggestions :)
Comment #32
Abeaudrian CreditAttribution: Abeaudrian commentedsubscribing... have same challenge.
...
Adrian
Comment #33
nirad CreditAttribution: nirad commentedI can confirm that #27 worked for me.
Comment #34
nkschaefer CreditAttribution: nkschaefer commentedI had the same problem, and moving the hidden div didn't seem to work for me either. I just spent a little time reading about the Google Maps API and everything, and I thought I'd share what I did in case it helps anyone else:
1) I'm actually using my own module to control the tabs, but it works almost exactly like Quicktabs (but I can make tabs for individual divs, rather than views, nodes, blocks, etc.). For that reason, I added a line to the JS to fire a custom event, "tabs-hide," when divs are hidden, and "tabs-show" when divs are un-hidden.
2) My GMap is part of a Views attachment. I have a custom helper module to alter the display of the view it's in; I wrote a hook_views_pre_render to add my own Javascript file before the View containing the GMap is shown. This Javascript contains an event listener for my custom "tabs-show" event.
3) Here's where I was confused: I couldn't find a function called "resizeMap" and someone said the map wasn't re-centering when using this function after un-hiding a GMap container. Instead, you need to:
Obtain the gmap by calling Drupal.gmap.getMap(yourmapID) (I think a frequently auto-assigned ID is 'auto1map').
Get a reference to the actual Google Maps object (lower-level than the GMap object) via the gmap object's map attribute.
Call map.checkResize() to fix its dimensions
Fix the latitude and longitude:
Get the latitude and longitude from the gmap object via [object].vars.latitude and [object].vars.longitude
create a GLatLng object with these numbers: new GLatLng(latitude, longitude, false)
Tell the Google Map object (not GMap object) about the coordinates: map.setCenter([GLatLng object you just created])
I realize my post isn't directly Quicktabs-related, but there was so much conversation about this issue here that I thought this would be the best place to post info. Maybe this can help save people time and prevent future questions on this topic.
The one implication this does have for Quicktabs is that maybe custom JQuery events should be fired whenever tabs are clicked to show or hide elements?
Comment #35
ccheu CreditAttribution: ccheu commented#27 didn't work for me. Has anyone tried #31? Any feedback is much appreciated! Cheers!
Comment #36
Aron Novak#31 is a good direction, but not perfect. I don't get it why using a fixed value.
I use this in gmaps.js (+Drupal.gmap.globalChange call in quicktabs.js + CSS fix from #27)
There is one drawback, it centers the map every time when the user changes between the tabs.
Comment #37
Danny EnglanderI am having the same issue, interested in this.
Note: #36 + #27 worked for me and switching tabs and then back to the tab with the map did not recenter the map if I had navigated with the map beforehand.
Comment #38
Tafa CreditAttribution: Tafa commented#27 worked for me too.
Thanks
T
Comment #39
Danny EnglanderI just discovered that IE 8 renders a nasty error message for the code in #36 (script debugging turned on).
The error I am getting is:
'Drupal.gmap' is null or not an object
I am not really good with Javascript so not sure how to further debug or solve this.
Comment #40
incaic CreditAttribution: incaic commented#27 worked for me, thanks!
Comment #41
EvanDonovan CreditAttribution: EvanDonovan commentedI added the CSS & JS solutions to a handbook page: http://drupal.org/node/1115726. I'll mark this fixed, then.
Comment #42
Danny EnglanderI don't believe this is fixed as I mentioned in comment #39 above, I am getting a nasty javascript error in IE 7, 8 & 9 so setting back to needs work.
Note that I have javascript debugging turned on. If you need more info, let me know but you should be able to reproduce it with that setting In any version of IE.
Comment #43
EvanDonovan CreditAttribution: EvanDonovan commented@highrockmedia: That is almost certainly a GMap issue (or an issue with JS in another module, besides GMap or Quick Tabs). Can you try following the debugging steps at http://drupal.org/node/1071244?
Also note that the code at #36 is really a last resort if you need it. Try the CSS method that I describe in the handbook page first.
I will mark this fixed again if no reports back in a week.
Comment #44
lennyaspen CreditAttribution: lennyaspen commentedI made the above necessary changes in respective places
but none seems to be working,
Please don`t close the topic yet.
Regards
Comment #45
GiorgosKput #27 in your own .css
fixes issue with gmap in hidden tab
and other issues http://drupal.org/project/galleryformatter thumbnails not appearing correctly
Comment #46
nkschaefer CreditAttribution: nkschaefer commentedMy last post was kind of obtuse -- but now I've hit a case where I have a Quicktabs block that contains other nested Quicktabs blocks, one of which contains three different maps (one per tab). This caused some problems, and the other suggested solutions didn't work. I built on my previous solution (above) and wrote some code that should be easy for anyone to dump into a custom module and solve the problem, without hacking anything.
Since you know better than anyone else what page/path your Quicktabs block will show on, you need to write a custom module that can add a custom Javascript file on the correct page. Or, if you want to take the easy way out, you can just write a hook_init() and add the Javascript file to every page.
Important: this Javascript file needs to be added AFTER the Quicktabs Javascript file, because its behavior must be bound after the Quicktabs behavior. In Drupal 7 this can be easily achieved by setting the "weight" parameter in drupal_add_js() -- something like this:
Use this Javascript file. You don't need the CSS trick above or anything - it'll fix up the right map whenever it's un-hidden via Quicktabs. And this works for my special case where I have a bunch of maps in nested Quicktabs blocks. This code is written for Drupal 7, but I'll also attach a version that's compatible with Drupal 6 (the changes are really small).
Comment #47
nkschaefer CreditAttribution: nkschaefer commentedHere's a Drupal 7 module that does everything above automatically (but not totally optimal performance-wise because it adds its Javascript to every page).
Comment #48
nkschaefer CreditAttribution: nkschaefer commentedAnd here's a Drupal 6 version of that same module. Hopefully this will help someone.
Comment #49
nadavoid CreditAttribution: nadavoid commentedsubscribing.
Comment #50
lennyaspen CreditAttribution: lennyaspen commented@nkschaefer
I applied your module
and the quicktab fix javascript loads after the quicktabs javascript itself
but the problem still persist
the only way to make it work is to make the gmap tab open as default
Comment #51
Exciliknite CreditAttribution: Exciliknite commentedSame problem with google charts api.
This is really annoying.
Comment #52
leahmd CreditAttribution: leahmd commentedsubscribing
eta:
I had just given up (again) for now after trying the css and gmap.js additions, it still wasn't working properly. I then went back and edited my location block gmap macro widths to finite px, width=400px | height=400px, instead of width=100%. It suddenly all worked on the refresh. Phew, I'll count myself lucky. Thanks all who contributed.
Comment #53
oceanos CreditAttribution: oceanos commented@purplepaisley68 - you just saved my life, just in time! I wondered why #27 didn't work for me - now it does!
@all others - thank you for this very helpful thread.
Comment #54
Marko B CreditAttribution: Marko B commented@nkschaefer why are you doing this only for quicktabs? I have the same problem with basic collapsing, this fix should be broadened if possible.
http://drupal.org/node/1352802#comment-5290440
Comment #55
Frederic wbase CreditAttribution: Frederic wbase commentedfor me the problem still exists for version 6.3.0 even after enabling the custom module and setting a fixed width & height in the gmap macro :(...
Any tips?
Comment #56
Marko B CreditAttribution: Marko B commentedSolve it like here http://www.drupaldump.com/gmap-center-and-resize-when-block-collapsed
Comment #57
Frederic wbase CreditAttribution: Frederic wbase commented@deepM
Your sollution didn't work for me, but i have fixed it by adding some javascript in the quicktabs.js on line 155
This sollution is based on http://drupal.org/node/352247#comment-4672750, just that i diden't used the module but only the js for recentering.
grts
fre
Comment #58
Frederic wbase CreditAttribution: Frederic wbase commentedIn combination with carouFredsel you can fix it like this:
Comment #59
Scott M. Sanders CreditAttribution: Scott M. Sanders commented#57 works great, albeit a little slow, but now it's centered.
Just in Quick Tabs 7.x-3.4, insert it in quicktabs.js at line 49.
And change "quicktabs_tabpage" to "quicktabs-tabpage".
Comment #60
Scott M. Sanders CreditAttribution: Scott M. Sanders commented#57 was giving me JS errors and somehow reloading the whole page on tab change -- because I do not actually use the legacy GMap module, just the iframe code from Google Maps.
But #27 works beautifully, fast with no reloading, and it solves not just Google Maps centering but anything that may render funny if hidden.
It should be added to Quick Tabs.
Comment #61
jienckebd CreditAttribution: jienckebd commented#27 worked great, thanks!!
Comment #62
ice70 CreditAttribution: ice70 commented@purplepaisley68 - thank you for the heads up on this one, it was driving me nuts seeing all the other users reporting success when I was getting a broken map :(
But, does any one have a solution to the 100% width map? I am using the Omega layout and there are several sizes this map could be depening on the screen size and 100% would be ideal!
Thank you for any pointers
ice70
Comment #63
oneidprod CreditAttribution: oneidprod commentedFor anyone who might be trying to get this to work with the accordian tab style and building off of #27 using 7.x-3.4 this worked for me.
.ui-accordion-content {
display: block !important;
position: absolute !important;
left: -10000px;
}
.ui-accordion-content-active {
left: 0px !important;
position: relative !important;
}
If you don't want to apply to every accordian block then you can use this
#block-quicktabs-yourblockname .ui-accordion-content {
display: block !important;
position: absolute;
left: -10000px;
}
#block-quicktabs-yourblockname .ui-accordion-content-active {
left: 0px !important;
position: relative;
}
Make sure you use the !important element or this won't work. Also, the !important element won't work in IE6. I started with the 2nd example that's why there's extra !important elements in the 1st example as they were needed when applied for every accordian block.
Comment #64
jordiserra CreditAttribution: jordiserra commented#27 works, but in my case I have 4 tabs, and this affected all other tabs. I applied this CSS only to the gmap tab, using the tab ID.
Thanks for this thread!
Comment #65
steven_kropp CreditAttribution: steven_kropp commentedI second that!
I had exactly the same issue, and thought I was going crazy over here... and yes I am too using Omega, and am wondering if I can't use 100% width... how am I going to execute this on my tablet and mobile versions.
Did you find any solutions?
Comment #66
brandy.brown CreditAttribution: brandy.brown commented#47 used in conjunction with #12 worked for me. Thank you!!!!
Comment #67
LWB CreditAttribution: LWB commented#27 worked great except it doesn't work again when making the gmap width 100% (as stated in 65). Any solution for this?
Comment #68
brandy.brown CreditAttribution: brandy.brown commentedDid you try using #47 with #12? I used that combo and am able to display maps at 100%.
Comment #69
miccelito CreditAttribution: miccelito commentedStated in the thread the Google Map Centering issue fix for css is
But this seems to work only when qtabs IS NOT Ajax.
Any additional css for showing Google Map when qtabs IS Ajax?
Comment #70
modiphier CreditAttribution: modiphier commentedperfect.. thanks! #69 worked perfectly for me. I have a default tab with a content node and then I have 9 additional tabs each with a separate embedded gmap nodes. This css corrected all of them loading to the correct view instead of all my markers out of view.
thanks
Comment #71
Marfio CreditAttribution: Marfio commented#27 worked.
I was with the same truble as #70
Thank you
Comment #72
vijeesh@fingent CreditAttribution: vijeesh@fingent commentedThis code worked for me:-
Comment #73
diegops CreditAttribution: diegops commented#72 worked for me...
Comment #74
Shiraz Dindar#72 worked for me as well (my issue being the google map was only partially rendered, ie. lots of grey area for google maps inside a quicktab when not in the first tab. In my case the map is a geofield google map display and the tabs are created programmatically as node tabs)
Thank you @vijeesh and all!
Comment #75
junkbox CreditAttribution: junkbox commented+10,000
Thanks Vijeesh! (#72)
Comment #76
travis09 CreditAttribution: travis09 commented#72 worked for me for a QuickTabs and multiple Fullcalendar views. Thanks Vijeesh.
Comment #77
Malek75 CreditAttribution: Malek75 commented#72 worked for me. Thanks!
Comment #78
wasimhyder09 CreditAttribution: wasimhyder09 as a volunteer and commentedComment # 27 worked for me.
Thanx @EvanDonovan.
You saved my day :)
Comment #79
joro78 CreditAttribution: joro78 as a volunteer commented#72 Worked, thanks Vijeesh.
Comment #80
stpaultim CreditAttribution: stpaultim as a volunteer commentedI had opened a similar issue #2915606: Maps don't render if they are not the default tab - The CSS provided in #72 solved my problem. Thanks!
Comment #81
Nick Hope CreditAttribution: Nick Hope commented#72 worked for me with Quick Tabs 8.x-3.0-alpha2 and Geolocation Field 8.x-2.0-beta1. Thanks vijeesh!
Comment #82
apadernoI am closing this issue, since it's for a Drupal version no longer supported.