【问题标题】:Google map auto complete component filtering谷歌地图自动完成组件过滤
【发布时间】:2013-08-05 07:34:15
【问题描述】:

与jquery ui自动完成一起使用时如何在地理编码中使用组件过滤

$("#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(),
                            loc :item.formatted_address   
                        }
                    }));
                })


    })
})

我想要这样的组件过滤http://maps.google.com/maps/api/geocode/json?address=santa+cruz&components=country:ES&sensor=false

【问题讨论】:

标签: php javascript jquery-ui google-maps geocoding


【解决方案1】:

您为什么不使用 Google 的 Places Autocomplete 库...(因为您希望在地理编码后自动完成)

var autoCompleteOptions = {
    componentRestrictions: {country: 'us'} //any country you want
    };

autocomplete = new google.maps.places.Autocomplete($('#address')[0], autoCompleteOptions);

【讨论】:

    【解决方案2】:

    希望这样的东西对你有用..

    geocoder.geocode( {'address': request.term ,components=country:ES}, 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-03-15
      • 2016-11-17
      • 2018-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多