//微信地图 微信小程序 sdk
import QQMapWX from "@/static/js/qqmap-wx-jssdk.min.js";
let qqMapSdk = new QQMapWX({
    key: "OFWBZ-2NTHP-EHNDD-LKWQY-GANM7-PXBJH"
});

//计算距离 shish 2020.5.14
export function calculateDistance() {
    var dis = 0;
    qqMapSdk.calculateDistance({
        from: {
            latitude: 39.98406,
            longitude: 116.30752
        },
        to: [
            {
                latitude: 40.98406,
                longitude: 116.51752
            }
        ],
        success: function (res) {
            console.log(res);
            var res = res.result;
            for (var i = 0; i < res.elements.length; i++) {
                dis = res.elements[i].distance
            }
        },
        fail: function (error) {
            //console.error(error)
        },
        complete: function (res) {
            //console.log(res)
        }
    });
    return dis;
}

export default {
    calculateDistance
}