views:

678

answers:

3

I pretty consistently get GMaps API javascript exceptions that look like the following:

  • Ve.k is null or not an object (FF & IE)
  • b.k is null or not an object (FF & IE)
  • a is null (FF)
  • a.$e is undefined (FF)
  • Uncaught TypeError: Cannot read property 'k' of undefined (chrome)

Often the exception occurs during an eval of some expression in javascript in the bowels of the GMaps API

Almost anything can cause one of these to pop up, displaying an overlay on the map or a mouse click event for example.

I've been scouring my code for some time looking for offending overlays, and event handlers, but so far no relationship found. I've had this happen on a naked map with no overlays or handlers active.

Certain versions of the API will not crash on certain browsers, but it's hit and miss and I still have this sinking susspicion that something in the environment is giving GMaps a hard time (eg. maybe Facebook Connect, Google Analytics, my code...)

Does anyone have a handle on what causes these?

+1  A: 

I would have to guess it would be your code (not to say your a bad programmer) or another library interfering. I've been using the Google MAPS API happily for about 1 year now* and never had the first exception. The only time I've ever gotten an error message was when I was adding the balloon thingy.

*The website looks like crap but it was a high school project for my county fair and I couldn't use any server side stuff.

Edit: After reading your comment I'm wondering if you included a proper DOCTYPE? Check and see if you have it.

Lucas McCoy
well, this is a more complex story than I led on. I have several pages that I've hand coded Javascript for the maps api and I don't get exceptions there ever, the pages I do get exceptions on, the javascript is created by GWT using a mapping library called Mapitz that I've been porting forward for the last year or so. It's not a simple GWT problem as I've compiled 'pretty' which does not minify the code generated by GWT so no collisions possible there... This one has been mad harder to debug because it doesn't crash in IE6 which is the hosted browser used by GWT debugging.
jottos
solved, see answer below
jottos
+1  A: 

Just the perils of using a minified, obfuscated Javascript library I am afraid. There is no discrete group of errors that result in the exceptions you are seeing, but you can be sure that they are a result of a bug in your own code. I use Google maps pretty extensively and have regularly seen these types of errors. In 100% of cases, the bug was mine.

If you post (either here or in new questions) specific examples of pages that generate these errors, we can check them out and hopefully fix them.

Cannonade
I'm also convinced that it's interaction with my application, but per my comment above, my handcoded javascript pages never crash, but the application built on GWT/Mapitz does. This makes it hard for me to post a useful example as even a "pretty" compiled GWT program is pretty opaque. BWT - liked your mapping stuff on your site, nice use of Simile, I didn't realize that it was available for use
jottos
Yep, GWT will definately complicate things. Re: my site, thanks very much :). I am using a great JS library called Timemap (http://code.google.com/p/timemap/). Nick Rabinowitz has done a great job hooking up Simile and Google Maps.
Cannonade
thanks for pointer to 'timemap'!
jottos
No problem, I am really enjoying playing with it. I'm glad you sorted out your problem, but have been meaning to come back and check out your solution. Finding ten minutes to sit down and think about your answer has been problematic of late. I intend to get their eventually.
Cannonade
+2  A: 

After spending quite a bit of time rolling back operations that affected the map 1 by 1, I finally got to the line(s) that caused this problem.

First, if I removed the call to setUIToDefault() the problem went away, this was unacceptable to me both because I wanted the default UI and that's a lame way to solve the problem. So many more map operations later I came to the GWT calls:

mapWidget.setHeight()
mapWidget.setWidth().

For those not familiar with GWT these two calls will ultimately translate to the following javascript template call:

element.style['height'] = height;

where 'element' in this case is the div that contains the map and height on the RHS of the expression is something like "690px".

That was all it took to derail the maps API.

The fix? Setting the size of the map div prior to instantiating the map.

You tell me, bug in the maps api or just a major feature lack? I'm going to check w/ the maps folks.

jottos
The verdict from maps folks is that this problem is the following issue that should be fixed soon!http://code.google.com/p/gmaps-api-issues/issues/detail?id=1479
jottos
So to confirm. This is a problem in IE6/7 when you resize the DIV containing the map after initialize (only when you use the default UI stuff)?
Cannonade
basically yes trying to resize the map as was the cause, the gmap.setUIToDefault() was also part of the issue as I had discovered. I was also able to get at least 1 JS crash out of FF and Chrome as well as the IE platform (see http://code.google.com/p/gmaps-api-issues/issues/detail?id=1479)
jottos
Cannonade
the Gmaps folks are pretty good at keeping the issues list current, just check the link I left in the previous comment - they are also god at prioritizing things that get a lot of community chatter for fixing
jottos
Reported fixed by Gmaps teamUpdates: Status: Fixed Labels: Fixed-2.169
jottos