开发者

How can I extend autocomplete's source in the course of geocoding

开发者 https://www.devze.com 2023-03-26 07:19 出处:网络
I create an autocomplete field like that for the Google Maps. It\'s working, but I need to extend the address list with my own points (specifically with category). The autocomplete function\'s source

I create an autocomplete field like that for the Google Maps. It's working, but I need to extend the address list with my own points (specifically with category). The autocomplete function's source option needs the extending:

  gc = new google.maps.Ge开发者_如何转开发ocoder();
  $(Element).autocomplete({
    source: function(request, response) {
      gc.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()
          }
        }))
      })
    },
    select: ...
  });

Any idea? Thank you in anticipation

0

精彩评论

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