9 Replies Latest reply on Jul 27, 2007 1:16 PM by sergeysmirnov

    gmap not rendered in firefox

    hispeedsurfer

      Have deployed the war file from richfaces-demo to jboss-4.2.0 now successful.
      The problem appears only in Firefox not in IE (7).

      The region is empty, no error-text, nothing. In firebug I can see the following

      <div class="dr-gmap rich-gmap" id="j_id102" style="width: 400px; height: 400px;">
      <script src="http://maps.google.com/maps?file=api&v=2&key="<skip>"
      type="text/javascript"/><script type="text/javascript">
      //<![CDATA[
      
      
      function __initGMap() { __initGmapdiv("map","j_id102", "Your browser does not support Google Maps");
       __applyGmapparam("map",37.9721046, -122.0424842834,17,G_SATELLITE_MAP,true,true,false,false,true,true,true);
       var userfunc = new Function('event', ''); userfunc();};__addLoadEvent(__initGMap);
      
      //]]>
      </script></div>
      


        • 1. Re: gmap not rendered in firefox
          hispeedsurfer

          Additonal info:

          in online version the problem doesn't appear (http://livedemo.exadel.com/richfaces-demo/)

          Have deployed richfaces-demo from svn and from nightly-build

          • 2. Re: gmap not rendered in firefox

            google map requires it own key registered for each domain. So, you need to take the key from Google and use it - attribute "gmapKey"

            richFaces Google map component allow to specify several keys, so you will be able to test application on the "localhost" and then deploy it to the production.

            Look at createKey() method at: http://tinyurl.com/2axh5o

            • 3. Re: gmap not rendered in firefox
              hispeedsurfer

              Unfortunately thats not the reason because map is displayed in Internet Explorer(v7).
              Anyway I have changed the key but the result is the same. Cannot show maps in richfaces-demo build from svn and it's not showed in my own app as well.

              • 4. Re: gmap not rendered in firefox
                hispeedsurfer

                hey Sergey,

                here some more infos.

                Tried gmap-sample.war and no problem. On richfaces-demo from svn it's always the same, also in my app. But in firebug 2 errors are thrown when I call gmap site.

                Object cannot be created in this context" code: "9
                getElementsByClassName("title", "span", undefined)menu.js (line 123)
                init()menu.js (line 42)
                [Break on this error] undefined
                GMap2 is not defined
                __initGmapdiv("map", "j_id183", "Your browser does not support Google Maps")gmap.js.jsf (line 12)
                __initGMap()gmap.jsf (line 620)
                [Break on this error] window[mapVar] = new GMap2(mapdiv);
                


                I have searched "GMap2 is not defined" error and found that I have to clear cache in firefox. No success.

                • 5. Re: gmap not rendered in firefox

                  try to surround content of the page with <f:view contentType="text/html">

                  • 6. Re: gmap not rendered in firefox
                    hispeedsurfer

                    Great Sergey,

                    that's the solution. How can I figure out such reason?

                    • 7. Re: gmap not rendered in firefox

                      Frankly speaking, I do not know the primary reason either.

                      richfaces-demo works under JSF 1.2 with Facelets
                      gmap-sample works under JSF 1.1 and without Facelets.

                      In general, facelets starts to set the content type to "xhtml" by default when recognizes the jsf 1.2. However, IE does not not support it and continues with "text/html". FF does support.

                      So,based on your feedback, the difference between "working vs. broken" is a content type.

                      http://jira.jboss.com/jira/browse/RF-457 has been created for further investigation.

                      • 8. Re: gmap not rendered in firefox
                        rnabuurs

                        I had the same problem as you. This is a known problem with Google Maps. See the Google Forums at http://tinyurl.com/yos773

                        Basically the problem is that when you supply a page with a mime-type of text/xhtml+xml to firefox it will parse it using it's xml parse. So the result is an xml document and not a html document.
                        Google Maps then tries to use the javascript call "document.write()" on that xml document, which fails because "document.write()" is html only (see http://www.mozilla.org/docs/web-developer/faq.html#accept )
                        IE doens't have this problem because IE doens't support XHTML and will treat is as ordinary html

                        You workaround (that i'm using as well) works because it forces firefox to use it's SGML parser instead of it's XML parser to parse the document.

                        I don't think you'll be able to fix this problem in richfaces... the real fix will have to come from Google

                        • 9. Re: gmap not rendered in firefox

                          Thank you for info. I see people try to find workaround, but not one exists that allow to fix this problem in general. Let's wait Google's guy.

                          So far, if you use Facelets, the problem is fixed easy with declaring the "text/html" content type explicitly with

                          <f:view contentType="text/html">


                          As soon as Facelets does not care where you put f:view, you can put it anywhere on the page, even inside the template that contains gmap.

                          BTW: Starting from version 3.1.0 (future August release), RichFaces will have a rich:virtualEarth component. This is an alternative from MS. What is interesting, but, by default, the same problem there also: http://viavirtualearth.com/vve/Forum/2/3.ashx