【问题标题】:How to save a CLLocation with Cloudkit JS如何使用 Cloudkit JS 保存 CLLocation
【发布时间】:2020-02-29 23:12:20
【问题描述】:

我正在使用 Cloudkit JS 将数据保存到公共数据库。当字段都是字符串时,它很容易做到。我现在正试图弄清楚当字段类型是 CLLocation 时如何保存数据。不知何故,我需要构造 JavaScript 以发送纬度和经度值。

看到 ???在下面的代码示例中;

var new record = { recordType: "Thing",
    fields: {   name: { value: "My Name" },
                description:  { value: "My Description" },
                location: { ??? }
    }
};

有谁知道如何获取经纬度坐标并在上面的代码中表示它们?

【问题讨论】:

    标签: cloudkit cloudkit-js


    【解决方案1】:

    尝试像这样传递它:

    fields: {
        location: { value: { latitude: lat, longitude: lng }, type: "LOCATION" }
    }
    

    latlng 是双精度,而不是字符串

    【讨论】:

    • 谢谢先生。这完美地工作并且 type: “LOCATION” 部分是可选的
    猜你喜欢
    • 2018-03-01
    • 1970-01-01
    • 2014-11-30
    • 1970-01-01
    • 1970-01-01
    • 2014-09-07
    • 2011-04-17
    • 1970-01-01
    • 2019-01-25
    相关资源
    最近更新 更多