nwebb

Flex, Flash, AIR

GoogleMaps API (geocoding Error #1006 & solution)

Update: the issue in this post has been confirmed as a bug - see bottom of post for more info

I was playing around with the GoogleMaps API a bit more yesterday and came across an annoying error. The same error can be seen on one of the Google examples (you will need the Flash debug player to see it): http://gmaps-samples-flash.googlecode.com/svn/trunk/examples/GeocodingSimple.html

1) Press the 'search' button
2) Scroll the map to a different location (not strictly necessary)
3) Press the 'search' button again.

The error is:

TypeError: Error #1006: processReply is not a function.
at MethodInfo-634()
at com.google.maps.core::DelayHandler/timerCallback()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()

Anyway, I had a look through the API and found that calling resetCache() just before you call geocode() solves the issue. It doesn't matter if you instantiate a new instance of ClientGeocoder
each time or if you try setting _geocoder to null - it looks like you still need to reset the cache. Here is an example:

Actionscript:
  1. private function geocode(address:String, resultFunc:Function, faultFunc:Function):void
  2. {
  3.         _geocoder = new ClientGeocoder();
  4.         _geocoder.addEventListener(GeocodingEvent.GEOCODING_SUCCESS, resultFunc, false, 0, true);
  5.         _geocoder.addEventListener(GeocodingEvent.GEOCODING_FAILURE, faultFunc, false, 0, true);
  6.         _geocoder.resetCache();
  7.         _geocoder.geocode(address);
  8. }

And that above method would be called like so:

Actionscript:
  1. public function setMarkerFromAddress(address:String):void
  2. {
  3.         geocode(address, geocodingSuccessHandler, geocodingFailureHandler);
  4. }


Update: this has been confirmed as a bug and so may not be an issue by the time you read this post.
Geocaching should work without resetting the cache. An issue has been created here should you wish to check its status.


Another point to make is that geocoding multiple addresses on page load is not recommended for several reasons:
1) Google's geocoder has a max number of queries per second.
2) Geocoding is not an aysnchronous operation. If possible you should geocode addresses before-hand rather than making users wait.

Thanks to Pamela for the recommendations and for filing the issue.

4 comments

4 Comments so far

  1. shinchi May 20th, 2008 1:23 pm

    Thanks, I am stuck in this too =)

  2. nwebb » GoogleMaps 101 May 23rd, 2008 8:56 am

    [...] Read this thread for information of a geocoding bug … it will hopefully be fixed by the time you read this post [...]

  3. [...] GoogleMaps API (geocoding Error #1006 & solution) [...]

  4. Bookmarks about Geocode December 9th, 2008 8:30 am

    [...] – bookmarked by 4 members originally found by c71123 on 2008-11-01 GoogleMaps API (geocoding Error #1006 & solution) http://nwebb.co.uk/blog/?p=198 – bookmarked by 1 members originally found by supersmashman666 on [...]

Leave a reply

Bad Behavior has blocked 517 access attempts in the last 7 days.