• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to call Google Map API in $(document).ready to get the country code?

 
Tony A Ng
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

I am facing a crisis here. I have a textbox, named businessInfo_businessAddress, which contains client's address loaded from the database when the page is loaded. I have a hidden field, named tracking-select-business-country-code



which is supposed to store the country code after the google map api is called.

In the included javascript file, where the google map api is called, I have piece of code like this



And in document.ready I have a piece of code that trying to call that function like this



I got this error in console.log


Uncaught TypeError: Cannot read property 'value' of null


I guess it must have something to do with variable autocomplete but I don't know how to handle this problem. I need after the form finishes loading (ie. $(document).ready is called), google map api must be called with the value contained in the textbox businessInfo_businessAddress (for example: "Atlanta, GA, United States") and return the country code for hidden field tracking-select-business-country-code. I wonder how can I do that? What change do I need to make in the code? Please help!!! Thanks everyone.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64718
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On what line is the error occurring?
 
Tony A Ng
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It occurred in the line but never mind. I found a better way to solve this problem. I'm using google.maps.Geocoder, easier than maps.places.
Thanks anyway.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic