2013-10-21 25 views
2

我們希望能夠在一個字段中輸入多個地址,並將輸入的地址保存爲標記(如these libraries),並使用Google地方信息自動填充功能作爲新輸入地址。Google地方信息自動填充可以在標籤編輯器字段中使用嗎?

有沒有人已經做到了這一點?

我使用tagedit與沒有運氣以下啓動嘗試:

$('input.tag').tagedit({autocompleteURL:"https://maps.googleapis.com/maps/api/place/autocomplete/json?input=",breakKeyCodes: [ 186]}); 

回答

2

我有相同的問題。我能夠使用Places AutoCompleteService和tagit完成此操作(http://aehlke.github.io/tag-it/)。 以下是基本設置

 var service = new google.maps.places.AutocompleteService(); 
     $('#myInputField').tagit(
       { 
        autocomplete: {source: function (req, callback) { 
         if (req.term.length > 2) { 
          service.getQueryPredictions({ input: req.term}, function (predictions, status) { 
           callback($.map(predictions, function ($val, $i) { 
            return $val.description; 
           })); 
          }); 
         } 
        }} 
        allowSpaces:true, 
        singleFieldDelimiter:'|' 
       } 
     ); 
相關問題