Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
47
rated 0 times [  52] [ 5]  / answers: 1 / hits: 49240  / 12 Years ago, mon, august 13, 2012, 12:00:00

Attempting to get auto complete working for my google maps application.



Here is the current code:



HTML



<input type=text class=clearText id=address name=address value= size=20 autocomplete=off>


Javascript



    var input = document.getElementById('address');
var options = {
componentRestrictions: {country: 'au'}
};
var autocomplete = new google.maps.places.Autocomplete(input, options);


Unfortunately nothing happens when typing an address.



Any ideas?



Thanks in advance.



Edit: I'm actually receiving the following error:



Uncaught TypeError: Cannot read property 'autocomplete' of undefined



Not sure why, the code is placed in my map initialize function.



Edit 2: Fixed. Answer below.


More From » google-maps

 Answers
32

Fixed. The autocomplete library is actually a separate library that must be explicitly loaded. The following line solved the problem.



<script type=text/javascript src=http://maps.googleapis.com/maps/api/js?libraries=places‌​&sensor=false></scr‌​ipt>

[#83681] Friday, August 10, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
maxd

Total Points: 568
Total Questions: 100
Total Answers: 101

Location: Serbia
Member since Tue, Jul 26, 2022
2 Years ago
;