-1

I recently started seeing an exception when calling the geocoder when it's called on a certain page. I'm pretty certain that there is something conflicting with the library, but I'm not quite sure what it is. The call is very simple so it's very surprising that anything else is interfering with the logic.

new google.maps.Geocoder().geocode(
    {address:'San Francisco, CA'}, 
    function(results, status){
        alert(status);
    }
)

This is the stack trace :

Uncaught TypeError: Cannot read property 'value' of undefined              VM41132:11
    GZ                                                                     VM41132:11
    H.Rm                                                                   VM41132:18
    (anonymous function)                                                    VM40916:1
    (anonymous function)                                     %7Bmain,places%7D.js:258
    (anonymous function)                                     %7Bmain,places%7D.js:887
    M                                                        %7Bmain,places%7D.js:244
    Xf                                                       %7Bmain,places%7D.js:886
    ag                                                       %7Bmain,places%7D.js:925
    (anonymous function)                                                   VM41132:19
    (anonymous function)                                                  VM41131:112
    (anonymous function)                                     %7Bmain,places%7D.js:896
    (anonymous function)                                     %7Bmain,places%7D.js:279
    (anonymous function)                                     %7Bmain,places%7D.js:902
    M                                                        %7Bmain,places%7D.js:244
    (anonymous function)                                     %7Bmain,places%7D.js:901
    Uf.(anonymous function).cf                               %7Bmain,places%7D.js:864
    Vf.(anonymous function).Yc                               %7Bmain,places%7D.js:893
    Zf                                                       %7Bmain,places%7D.js:907
    (anonymous function)                     %7Bcontrols,places_impl,geocoder%7D.js:2

Has anyone run into a similar issue?


EDITED

I guess since no one else have run into this issue, I will use this thread for sharing solution when I have figured it out. I will just have to strip out code block by block until I can narrow down the cause and then figure out what to do with it. It has to be something very simple, but I just have idea where to start. My initial guesses are the following:

  • Something is initializing the library before it is ready causing the library to not work properly (same issue as regular Google Maps API with its fall back mode)
  • A global variable is changed if it's relying on one
juminoz
  • 3,168
  • 7
  • 35
  • 52
  • We need to see more code, the supplied code as it is works fine – Dr.Molle Jan 19 '14 at 00:19
  • If I knew which block of code is causing the issue, I would have done it already. I was just wondering if someone else has run into a similar issue. There are at least 5k lines of code running on this page and it's most likely caused by something I didn't personally add. – juminoz Jan 19 '14 at 04:03

1 Answers1

0

You have to split your code to something like:

var geocoder = new google.maps.Geocoder();
geocoder.geocode(
    {address:'San Francisco, CA'}, 
    function(results, status){
        alert(status);
    }
);

google.maps.Geocode() is constructor, geocode() is a method. See google docs for Geocoding.

Anto Jurković
  • 11,188
  • 2
  • 29
  • 42
  • 1
    It doesn't matter. I tried both ways. In my actual code, this is what it looks like. I just copied the one above from console just to show that I'm calling it without anything else. It's some state in the UI that's probably causing the issue. – juminoz Jan 19 '14 at 00:08
  • It should be something else than because using similar example like [geocoding-simple](https://developers.google.com/maps/documentation/javascript/examples/geocoding-simple) works without problems. – Anto Jurković Jan 19 '14 at 00:29
  • It's definitely something else. I'm just not sure what is causing it. Still trying to narrow it down. – juminoz Jan 19 '14 at 04:04