获取/获取数据,是查询数据源的剑道下拉列表,并使用它在谷歌地图

Getting/Fetching Datas that is Queried on Datasource of Kendo DropdownList and use it on Google Maps

本文关键字:获取 谷歌地图 下拉列表 数据 查询 数据源      更新时间:2023-09-26

我可以问什么是获取值的方式在数据源查询和使用它,因为在我的Json结果有列的纬度和经度,我想用它来使地图中心的位置

下拉菜单的变化

这是我的位置下拉列表

        $("#ddlLocation").kendoDropDownList({
            dataTextField: "Address",
            dataValueField: "Client_CustomerID",
            autoBind: false,
            optionLabel: "-- Please Select Position --",
            template: '<h5>${ data.Address }</h5>',
            dataSource: {
                transport: {
                    read: {
                        url: '/Dashboard/LoadCompanyDropdownList?userId=' + userId,
                        dataType: "json",
                        type: "POST"
                    }
                }
            }          
        });
        $("#LocationInputs").kendoDropDownList({
            dataTextField: "Address",
            dataValueField: "Client_CustomerID",  
            //                    index: 0,
            autoBind: false,
            change: function () {
                var value = this.value();
                if (value) {

**This is where i want to use the fetched Latitude and Longitude**

                }
                else {
                    $("#PositionGrid").data("kendoGrid").dataSource.filter({});
                } 
            },
            cascadeFrom: "PositionInputs",
            optionLabel: "-- Please Select Position --",
            template: '<h5>${ data.Address }</h5>',
            dataSource: {
                transport: {
                    read: {
                        url: '/Dashboard/LoadCompanyDropdownList?userId=' + userId,
                        dataType: "json",
                        type: "POST"
                    }
                }
            }
        });

这是LoadCompanyDropdownList

 public JsonResult LoadCustomerList()
    {

        // check if search string has value
        // retrieve list of workers filtered by search criteria
        var list = (from a in db.Client_Customer_Location
                    join b in db.Client_Customer
                        on a.Client_CustomerID equals b.ID
                    where a.LogicalDelete == false
                          && b.LogicalDelete == false
                            && a.Longitude != null
                             && a.Longitude != 0
                    select new
                    {
                        b.ID,
                        a.Client_CustomerID,
                        a.Address_Line1,
                        a.Address_Line2,
                        a.City,
                        a.STATE_LookID,
                        a.ZipCode,
                        a.Latitude,
                        a.Longitude,
                        a.LogicalDelete,
                    }).ToList();
        List<CustomerInfo> clist = new List<CustomerInfo>();
        foreach (var row in list)
        {
            CustomerInfo ci = new CustomerInfo
            {
                ID = row.ID,
                Client_CustomerID = row.Client_CustomerID,
                ClientID = row.ClientID,
                AddressLine1 = row.Address_Line1 + " " + row.Address_Line2 + " " + row.City + " " + GetLookupDisplayValById(row.STATE_LookID),
                Latitude = Math.Round(Convert.ToDecimal(row.Latitude), 8),
                Longitude = Math.Round(Convert.ToDecimal(row.Longitude), 8),
                LogicalDelete = row.LogicalDelete
            };
            clist.Add(ci);
        }
        return Json(clist.ToList().OrderBy(p => p.AddressLine1), JsonRequestBehavior.AllowGet);
    }

你可以试试:

change: function () {
    var dataItem = this.dataItem(this.select());
    var lat = dataItem.Latitude;
    var long = dataItem.Longitude;
    var value = this.value();
        if (value) {
              ........
        }