开发者

Google Maps Dynamic Search Query Webservice with JSON

Hi I wish to replicate the dynamic search results returned when entering in a location google maps for example, I'm from Sydney Australia so when I bring up Maps and type "Kin" I get:

Maps Example http://img525.imageshack.us/img525/2042开发者_如何学运维/screenshot20101215at514.png.

But if I use the Geocoder webservice with a string example like:

http://maps.google.com.au/maps/api/geocode/json?address=Kin+,%20Australia&bounds=-46.08542,-4.39023%7C93.33984,157.67578&sensor=false&region=au

OR

http://maps.google.com.au/maps/api/geocode/json?address=Kin&sensor=false

OR

http://maps.google.com.au/maps/api/geocode/json?address=Kin&sensor=false&region=au

All I get returned is (Try it yourself):

Kinshasa, Democratic Republic of the Congo Arrivals (KIN), Kingston, Jamaica 4920 Kin, Belgium

ETC.

The one that attempts to limit it to australia returns only:

King Island, Loorana TAS 7256, Australia

Now I don't mind filtering the type to locality from the clientside, but why can't I get the EXACT same results as the Dynamic Search results returned from google maps itself.

Any help Most Appreciated! I've spent too long on this now...


The Geocoder is for resolving a valid address to a location on the surface of the Earth. It is not intended for use as a suggestions / auto-complete service.


I did this with jquery

// jquery autocompleta $(function() { $("#address").autocomplete({ //This bit uses the geocoder to fetch address values source: function(request, response) { geocoder.geocode( {'address': request.term }, function(results, status) { response($.map(results, function(item) { return { label: item.formatted_address, value: item.formatted_address, latitude: item.geometry.location.lat(), longitude: item.geometry.location.lng() } })); }) }, //This bit is executed upon selection of an address select: function(event, ui) {
//$("#latitude").val(ui.item.latitude); //$("#longitude").val(ui.item.longitude); //var location = new google.maps.LatLng(ui.item.latitude, ui.item.longitude); //marker.setPosition(location); //map.setCenter(location); } }); });

address is a textfield in the html file

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜