GMap disappears when two onload functions are used in <body> tag.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • flydev
    New Member
    • Feb 2008
    • 33

    GMap disappears when two onload functions are used in <body> tag.

    Hello,

    Thanks for taking the time to help. I'm having a problem with GMap and IE7 (could be occurring in earlier versions). First let me give you a link to the problem:

    problem

    The problem seems to manifest itself initially when you mouse over the "Choose a different route >>" link (which has onmouseover event to change font styles). It seems that having two functions in the onload command of the <body> tag is causing the map to disappear, and I can't for the life of me figure this out. One function is loading the map into the "map" DIV, and the other is loading route data into a separate hidden DIV (viewable when clicking the problem link).

    I am using scriptaculous to incorporate DIV slide effects for the hidden DIV, could this be causing the problem? Please let me know if any clarification is needed.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    Originally posted by flydev
    ...when you mouse over the "Choose a different route >>" link (which has onmouseover event to change font styles). It seems that having two functions in the onload command of the <body> tag is causing the map to disappear, ...
    can't verify that, the hovers toggle the colour (map stays where it is) and the click brings up the new route....

    tested on FF 3.0.5 / Mac OS X

    by the way, wouldn't it be easier to use CSS' :hover pseudo-class for the colour change?

    Comment

    • flydev
      New Member
      • Feb 2008
      • 33

      #3
      Originally posted by Dormilich
      can't verify that, the hovers toggle the colour (map stays where it is) and the click brings up the new route....

      tested on FF 3.0.5 / Mac OS X
      It only appears to happen in IE for some reason...Chrome and FF work fine.

      by the way, wouldn't it be easier to use CSS' :hover pseudo-class for the colour change?
      Yea, but I was being lazy, that was the only link i was working with at the time and didn't want to change all my style sheets. I changed it to a:hover now to avoid any confusion.

      Comment

      • flydev
        New Member
        • Feb 2008
        • 33

        #4
        Since I removed the onmouseover event, it doesnt happen when you mouse over the link, only when you click on it....that seems to imply this occurs whenever another javascript function is being executed.

        Comment

        • flydev
          New Member
          • Feb 2008
          • 33

          #5
          I moved all the javascript I could to the <head> section, and I am now using jquery instead of scriptaculous.. .this didn't help...it seems whenever ANY function or javascript is being called after the map is loaded, causes it to disappear....ag ain, only in IE

          You can duplicate this by click "Show more routes >>"...this triggers the listener in the <head> section to animate the DIV.

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            There's an error: "map is undefined" or "map is null or not an object" depending on the browser. I've not checked, but that may possibly be the source of the problem.

            Comment

            • Dormilich
              Recognized Expert Expert
              • Aug 2008
              • 8694

              #7
              maybe it helps to include the ajax script as the last one (if you execute your script before google defines its map object.....)

              Comment

              • flydev
                New Member
                • Feb 2008
                • 33

                #8
                Originally posted by acoder
                There's an error: "map is undefined" or "map is null or not an object" depending on the browser. I've not checked, but that may possibly be the source of the problem.
                Unfortunately not, that was just a function to trigger a map.checkResize I wrote to try to fix this, but it didn't fix the problem. I removed it. The map is now sized explicitly within the GMap function (instead of pulling its size from the DIV container)..so the map.checkResize is no longer applicable, but the problem still persists.

                maybe it helps to include the ajax script as the last one (if you execute your script before google defines its map object.....)
                Well, I did have both functions included in the onload of the <body> tag (GMap first, AJAX second), but that seemed to cause the map to disappear immediately. Now the onload only contains the GMap function, and the AJAX script is triggered by window.onload.. .that seemed to prevent the map from disappearing immediately.

                The problem doesn't seem to be the AJAX, it seems to be the DIV resize...whenev er a DIV is being resized (not the GMap DIV), it causes the map to disappear.

                Comment

                • flydev
                  New Member
                  • Feb 2008
                  • 33

                  #9
                  LOL, you know what...im about to smash something if i keep trying to figure this out, I'm 99% sure its just a bug when contents get redrawn on a page the map disappears in IE...I'll just have to use an iFrame (i hate iframes)...than ks much for your help guys!!

                  Comment

                  Working...