Meaningless Drivel is fun!*
The moose likes HTML, CSS and JavaScript and the fly likes How to call Google Map API in $(document).ready to get the country code? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to call Google Map API in $(document).ready to get the country code?" Watch "How to call Google Map API in $(document).ready to get the country code?" New topic
Author

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

Tony A Ng
Greenhorn

Joined: Apr 16, 2014
Posts: 3
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

Joined: Jan 10, 2002
Posts: 61103
    
  66

On what line is the error occurring?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Tony A Ng
Greenhorn

Joined: Apr 16, 2014
Posts: 3
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to call Google Map API in $(document).ready to get the country code?