After my recent success (with help from here), I wanted to finish up my script. Google agreed that it was ok to put the geocoded map result on the second page so I want to strip out the map display from my geocoding script on the first page.
I have this working here: /
BUT! The only thing it doesnt have is autosuggest (the google one, not a jqueryUI one). Here is some code which does demonstrate the google autosuggest: /
Now, the code that seems to enable the autosuggest is this:
var autoplete = new google.maps.places.Autoplete(address,options);
var autopleteOptions = {types: ['geocode']};
I added this to my original code and unfortunatly it doesnt work! This code can be seen here: /
So my question is, based on my original code in my FIRST LINK, how do I enable the google autoplete suggestions?
Any help or input you can give would be much appreciated! Thank you.
After my recent success (with help from here), I wanted to finish up my script. Google agreed that it was ok to put the geocoded map result on the second page so I want to strip out the map display from my geocoding script on the first page.
I have this working here: http://jsfiddle/njDvn/15/
BUT! The only thing it doesnt have is autosuggest (the google one, not a jqueryUI one). Here is some code which does demonstrate the google autosuggest: http://jsfiddle/Rr5PL/63/
Now, the code that seems to enable the autosuggest is this:
var autoplete = new google.maps.places.Autoplete(address,options);
var autopleteOptions = {types: ['geocode']};
I added this to my original code and unfortunatly it doesnt work! This code can be seen here: http://jsfiddle/njDvn/16/
So my question is, based on my original code in my FIRST LINK, how do I enable the google autoplete suggestions?
Any help or input you can give would be much appreciated! Thank you.
Share Improve this question edited Nov 3, 2012 at 17:38 Jimmy asked Nov 3, 2012 at 17:29 JimmyJimmy 12.5k29 gold badges114 silver badges206 bronze badges3 Answers
Reset to default 3Here is an Autoplete example, (US only), with Streetview included.
The key lines for creating it are:
var input = document.getElementById('searchTextField');
var options = {
types: [],
ponentRestrictions: {country: 'us'}
};
var autoplete = new google.maps.places.Autoplete(input, options);
You also need to load the Places library:
<script src="https://maps.googleapis./maps/api/js?sensor=false&libraries=places"></script>
and the HTML:
<input id="searchTextField" type="text" size="50" value="">
By the way, you don't "add autoplete to the geocoder".The Places Autoplete class includes geocoding capabilities.
The JavaScript Autoplete is part of the Google Places API, which is not loaded by default with the Google Maps API. You need to explicitly load the Places library when you include the Maps API by adding the parameter libraries=places
:
<script src="http://maps.googleapis./maps/api/js?libraries=places&sensor=false"></script>
Have a look at this ready demo, that does exactly what is mentioned by Marcelo and ssorallen http://devfestmtm.appspot./demos/places/autoplete_addressform.html
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745586900a4634596.html
评论列表(0条)