亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

google placecomplete 插件不再允許選擇地址

google placecomplete 插件不再允許選擇地址

莫回無 2023-01-06 15:07:30
我一直在使用這個腳本:https ://github.com/stephjang/placecomplete多年,沒有任何問題。今晚我收到很多投訴,用戶無法從下拉菜單中選擇地址。輸入地址可以正常工作并且會顯示結果,但是當嘗試選擇地址時,它不會執行任何操作。有誰知道谷歌阻止 placecomplete 請求是否發生了變化?我的代碼:$inputLocationSearch.placecomplete({         placeholderText: "Enter your site location...",         requestParams: {            componentRestrictions: {country: ['ca','us']}        }     });問題的屏幕截圖(鼠標或鍵盤無法選擇找到的地址):
查看完整描述

1 回答

?
qq_遁去的一_1

TA貢獻1725條經驗 獲得超8個贊

在插件jquery.placecomplete.js代碼中發現了問題。將默認id參數替換為 use place_id,因為id谷歌自動完成已棄用。


我補充說:apr["id"] = apr["place_id"];在現有代碼之上:apr["text"] = apr["description"];


這是添加的整個代碼塊:


var select2options = $.extend({}, {

        query: function(query) {

            GooglePlacesAPI.getPredictions(query.term, requestParams)

                .done(function(aprs) {

                    var results = $.map(aprs, function(apr) {

                        // Select2 needs a "text" and "id" property set

                        // for each autocomplete list item. "id" is

                        // already defined on the apr object

                        apr["id"] = apr["place_id"];

                        apr["text"] = apr["description"];

                        return apr;

                    });

                    query.callback({results: results});

                })

                .fail(function(errorMsg) {

                    $el.trigger(pluginName + ":error", errorMsg);

                    query.callback({results: []});

                });

        },

        initSelection: function(element, callback) {

            // initSelection() was triggered by value being defined directly

            // in the input element HTML

            var initText = $el.val();


            // The id doesn't matter here since we're just trying to prefill

            // the input with text for the user to see.

            callback({id: 0, text: initText});

        },

        minimumInputLength: 1,

        selectOnBlur: true,

        allowClear: true,

        multiple: false,

        dropdownCssClass: "jquery-placecomplete-google-attribution",

        placeholder: this.options.placeholderText

    }, this.options);


查看完整回答
反對 回復 2023-01-06
  • 1 回答
  • 0 關注
  • 94 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號