2

We'd like to be able to enter many addresses in one field, saving entered ones as tags (as these libraries do) and using Google Places Autocomplete as a new one is typed.

Has anyone achieved this already?

I've tried using tagedit with the following startup with no luck:

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

1 Answers1

2

I had the exact same issue. I was able to accomplish this using Places AutoCompleteService and tagit (http://aehlke.github.io/tag-it/). Here's the basic setup

        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:'|'
                }
        );
Neelesh
  • 76
  • 2