Google Maps Polygon & Ployline TypeError 1009

Posted: July 6, 2009 in Flex, Google Maps
Tags: ,

Earlier I was throwing together a quick and dirty KML parser with the aim of getting some county regions onto a Google Map.

Services were fired off on initialise, loaded up a static KML file, parsed it and passed the Polygons/Polylines back to be placed upon the map. However I was getting a TypeError: Error #1009: Cannot access a property or method of a null object reference from within my parser at the point I was constructing the Polygon or Polyline. Why?!

An hours fist shaking and tea drinking later I discovered that the null it was complaining about was that the Google Map instance had not yet been created (NOT documented behavior). WHY it needs a map instance at all at this point is plain stupid, made even more so by failing to give you a meaningful error message beyond the TypeError 1009.

Lesson here then, if TypeError 1009 is popping up for no reason, check that your Google Map instance hasn’t wondered off.

Comments
  1. dsjbirch says:

    Site looks great. How did you figure out that was the problem? I’ve been staring at that same error for hours now, alhamdulila, your post pointed me in the right direction.

    • Phil Ostler says:

      Hi, glad that helped. The product I was working on at the time had a somewhat backwards startup sequence so thought it was worth checking to see if it was somehow dependant on the map instance existing. I can’t find this documented so was worth a blog entry

Leave a comment