在剑道UI自动完成中使用Google Places API

Using Google Places API in Kendo UI Autocomplete

本文关键字:Google API Places UI      更新时间:2023-09-26

我试图在我的移动web应用程序中使用Google Places API (Places Autocomplete)在我的Kendo UI Autocomplete中,但我很难找到如何做到这一点的教程。

这就是我现在所做的。

        requestUrl = "https://maps.googleapis.com/maps/api/place/autocomplete/json";
        var dsLocations = {
            serverFiltering: true,
            type: "odata",
            transport:
            {
                read: {
                    url: requestUrl,
                    dataType: "json",
                    contentType: "application/json",
                },
                parameterMap: function (options, operation) {
                    var paramMap = kendo.data.transports.odata.parameterMap(options);
                    delete paramMap.$inlinecount; 
                    delete paramMap.$format; 
                    return paramMap;
                }
            },
            schema: {
                data: function (data) {
                    return data;
                },
                total: function (data) {
                    return data.length;
                },
            },
        };
        $("#autocomplete-locations").kendoAutoComplete({
            dataSource: dsLocations,
            minLength: 3,
            filter: "contains",
            dataTextField: "TextForSearch",
            dataValueField: "TextForSearch"
        });

明白了!你甚至不需要剑道。

https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-addressform