【问题标题】:How to add tags using Geolocation with Tags Input?如何使用带有标签输入的地理位置添加标签?
【发布时间】:2015-07-30 23:49:57
【问题描述】:

我想添加谷歌地理位置地址的标签输入。

我正在使用这个地理位置 Autofill Address + Google Maps API

这是引导标签输入。 http://timschlechter.github.io/bootstrap-tagsinput/examples/

如果我输入地址并选择自动完成地址,它应该转换成类似引导标签的标签。

【问题讨论】:

    标签: autocomplete google-geolocation bootstrap-tags-input


    【解决方案1】:

    我使用带有引导标签输入的 Twitter Typeahead 的解决方案:

            var locations = new Bloodhound({
                datumTokenizer: Bloodhound.tokenizers.obj.whitespace('formatted_address'),
                queryTokenizer: Bloodhound.tokenizers.whitespace,
                identify: function (obj) {
                    return obj.place_id;
                },
                remote: {
                    url: 'https://maps.googleapis.com/maps/api/geocode/json?address=%QUERY&language={YOUR_LANGUAGE}&key={YOUR_MAPS_API_KEY}',
                    wildcard: '%QUERY',
                    rateLimitWait: 100,
                    transform: function (response) {
                        if (response.status === 'OK') {
                            return response.results;
                        } else {
                            return [];
                        }
                    }
                }
            });
            $('input').tagsinput({
                itemValue: 'place_id',
                itemText: 'formatted_address',
                typeaheadjs: [{
                    highlight: true
                }, {
                    displayKey: 'formatted_address',
                    source: locations
                }],
                trimValue: true
            });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多