Re: IE8 is indicating a script error with the Map when implementing functionality similar to the getMyLocation demo page

25 views
Skip to first unread message

Hazem Saleh

unread,
May 3, 2013, 3:20:24 PM5/3/13
to gmaps4...@googlegroups.com, gmaps4...@googlegroups.com
Put the map component inside a h:panelGroup, and in the richfaces Ajax render attribute specify the panelGroup id which contains the map.

If this does not work, let us know. 

Sent from my iPhone

On May 3, 2013, at 10:31 PM, Daniel Dausch <d.dau...@gmail.com> wrote:

I was able to resolve this issue by adding 'rendered' attribute and corresponding method to backing bean. I am now getting a diff issue. The first execution of the command button works fine - i see my data table and my map. The second attempt updates the data table but not the map. There is a browser error as follows:

ebpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E)
Timestamp: Fri, 3 May 2013 19:26:37 UTC


Message: Script error
Line: 0
Char: 0
Code: 0
URI: https://maps.gstatic.com/intl/en_us/mapfiles/api-3/12/10/main.js

-----------------------
Any thoughts about the root cause?


--------------------------------------------------------

On Friday, May 3, 2013 10:05:27 AM UTC-4, Daniel Dausch wrote:
I am using JSF 2.1.21 (Mojarra), RichFaces 4.3 and GMap4sf. My source code snippet is as follows:

           <h:form id="form2">
        
            <h:panelGrid columns="2">               
                <h:outputText value="Enter your address like 'Boston, MA' :"/>
                <h:inputText id="txtAddress" value="#{propertyBean.address}"/>               
                    <a4j:commandButton value="Get my location on the map" action="#{propertyBean.search}"
                         render="map2,myTable2"
                         limitRender="true">
                    </a4j:commandButton>                                                  
            </h:panelGrid>     
               <a4j:region id="regionMap">
            <h:panelGrid id="searchMap" columns="2" border="2" cellpadding="5px">
                                   
                   <m:map id="map2" width="450px" height="375px" partiallyTriggered="false" latitude="#{propertyBean.targetPlace.lat}"
 longitude="#{propertyBean.targetPlace.lon}">
                   </m:map>                      
               
                  <rich:extendedDataTable id="myTable2" var="place"
                          value="#{propertyBean.nearbyProps}"
                          rows="0" width="450px" height="100px">
        .......

I am using a a4j:commandButton which calls the 'search' method on a Backing Bean. This ends up creating a object called targetPlace and a list of nearby Properties to the target. On the render phase, the map remains blank but the Data Table is properly displayed. The only way to display the map is to refresh the entire page which of course defeats the purpose of using ajax. When trying to figure this out I did notice the script error in IE8 which seems to reference the map2 entity. I stripped out the markers and the like to make it simpler but still getting the same error and also the same refresh issue. It functions the same way in Mozilla. Here is a snippet form the source view of the page:

window.gmaps4jsf.createMap({id: 'form2:map2',enableScrollWheelZoom: false,zoom: 11,location: {latitude: , longitude: , address: ''},
jsVariable: '', parentFormID: 'form2', mapType: google.maps.MapTypeId.ROADMAP, submitOnValueChange: 'false',
mapStateHiddenFieldID: 'com_googlecode_gmaps4jsf_mapStatemap2', showDefaultControls: 'true',
 autoReshape: false, ajaxBehavior: {}}, function (parent) {

--
You received this message because you are subscribed to the Google Groups "gmaps4jsf-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gmaps4jsf-de...@googlegroups.com.
To post to this group, send email to gmaps4...@googlegroups.com.
Visit this group at http://groups.google.com/group/gmaps4jsf-dev?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Hazem Saleh

unread,
May 6, 2013, 11:46:04 AM5/6/13
to gmaps4jsf-dev
I noticed that in your code sample you put: partiallyTriggered="false"
This is why the map does not appear.

In order to update the map with Ajax, you have to set partiallyTriggered to true:
http://code.google.com/p/gmaps4jsf/wiki/mapComponent

Change this attribute to true and it will work.

Let us know if the issue still exists.


On Mon, May 6, 2013 at 3:52 PM, Daniel Dausch <d.dau...@gmail.com> wrote:
As per your instructions, I nestled the map inside a h:panelGroup but still doing the same thing. I also removed the a4j:Region that I had and also removed the limitRender="true" attribute on the commandButton - still not working. I have been doing JSF and RichFaces for a number of years so I am not new at this. Any other suggestions?



--
Hazem Ahmed Saleh Ahmed

Author of JavaScript Unit Testing book:
http://www.amazon.com/dp/1782160620/

Co-author of (The Definitive Guide to Apache MyFaces and Facelets) book:
http://www.amazon.com/-/e/B002M052KY

DeveloperWorks Contributing Author
https://www.ibm.com/developerworks/mydeveloperworks/blogs/hazem/entry/ibm_developerworks_contributing_author?lang=en_us

An Apache committer, IBMer, and a technical speaker

Twitter: http://www.twitter.com/hazems

Hazem Saleh

unread,
May 6, 2013, 12:01:46 PM5/6/13
to gmaps4jsf-dev
I believe it is misstated, I just updated it now to be more clear. Thanks for the good notice.


On Mon, May 6, 2013 at 5:57 PM, Daniel Dausch <d.dau...@gmail.com> wrote:
As per your instructions, I changed it to 'true' and it seems to work now - need to do some more testing. I had read the doc on the mapComponent and it says the following:

This flag determines whether to render the map on window load. This flag should be set to false if the map is inside a zone that will be updated by Ajax.

The way I read this was to set it to 'false' because I am updating it via Ajax. Did I read this wrong or is it misstated?

Hazem Saleh

unread,
May 6, 2013, 12:17:11 PM5/6/13
to gmaps4jsf-dev
You are welcome :)


On Mon, May 6, 2013 at 6:13 PM, Daniel Dausch <d.dau...@gmail.com> wrote:
I am glad there was a simple solution and that an error was caught in the doc - it was driving me crazy for a couple of days. Thanks for the help and the prompt responses.
Reply all
Reply to author
Forward
0 new messages