您好,我希望复制输入谷歌地图时返回的动态搜索结果。例如,我来自澳大利亚悉尼,所以当我打开地图并输入"Kin“时,我会得到:
Maps Example http://img525.imageshack.us/img525/2042/screenshot20101215at514.png。
但是如果我使用具有字符串示例的地理编码器use服务,例如:
http://maps.google.com.au/maps/api/geocode/json?address=Kin+,%20Australia&bounds=-46.08542,-4.39023%7C93.33984,157.67578&sensor=false®ion=au
或
http://maps.google.com.au/maps/api/geocode/json?address=Kin&sensor=false
或
http://maps.google.com.au/maps/api/geocode/json?address=Kin&sensor=false®ion=au
我得到的结果是(自己试一试):
金沙萨,刚果民主共和国抵达人数( Kin ),金斯敦,牙买加4920金,比利时
等。
试图将其限制在澳大利亚的人只返回:
澳大利亚罗拉纳州TAS 7256,国王岛
现在我不介意从客户端过滤类型到位置,但是为什么我不能得到与google地图本身返回的动态搜索结果完全相同的结果。
任何帮助都非常感谢!我已经在这上面花了太长时间了..。
发布于 2010-12-16 19:37:11
地理编码器用于将有效地址解析为地球表面上的位置。它不打算用作建议/自动完成服务。
发布于 2010-12-19 10:14:50
我用jquery做到了这一点。
// jquery .autocomplete $(function() { $("# address ").autocomplete({ //此位使用地理编码器获取地址值来源: function(request,response) { geocoder.geocode( {'address':request.term },function(results,status) ){response($.map,function(item) { return { label: item.formatted_address,取值: item.formatted_address,纬度: item.geometry.location.lat(),经度: item.geometry.location.lng() } }));}) },//此位在选择地址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); } }); });
地址是html文件中的文本字段。
https://stackoverflow.com/questions/4447287
复制相似问题