Monday, March 30, 2009

JavascriptException with Gwt Maps 1.0.3 (using GWT 1.5.3)

I had a google MapWidget that has several marker overlays. When run
in hosted mode, these markers can be seen. However, once compiled into
Javascript, the following error is thrown in Firefox:

Error: [Exception... "'
(TypeError): a is null
lineNumber: 532
stack: (null,"C:\\myIcon.png",[object Object])@
l2([object Object])@http://localhost:8080/MyProject/
C1([object Object],[object Object])@http://localhost:8080/MyProject/
mx([object Object],[object Object])@http://localhost:8080/MyProject/
px([object Object])@http://localhost:8080/MyProject/
([object Event])@http://localhost:8080/MyProject/
' when calling method: [nsIDOMEventListener::handleEvent]" nsresult:
"0x8057001c (NS_ERROR_XPC_JS_THREW_JS_OBJECT)" location: ""
data: no]

Hence, in both Firefox and IE, I couldn't seem to see the markers.

The reason for this is my use of absolute paths rather than relative paths. Ensure that the marker's icon is not on an external absolute URL. The markers I was using used an icon from C:\MyIcon.png. When this is deployed as a war file in Firefox and IE, the marker's icon src was null as it could not point to that URL in web mode. Solution: Ensure that the icon is
in the 'public' folder in your project. Eg. My images are in the 'public/images' folder and hence the icon's url is:
Icon icon = Icon.newInstance("images/MyIcon.png");

This will be visible in webmode when deployed using a war file.

No comments:

Post a Comment

Thank you for your comment.