javascript 使用免费增值API在地图上获取两点的getDistance

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript 使用免费增值API在地图上获取两点的getDistance相关的知识,希望对你有一定的参考价值。

// See API if we can parse options.
// Minimum 2 latLng objects should be parsed to the API.
// The first object is the home address where we are, 
// and the second is where we want to go.
// 15.000 monthly requests free.

var locations = [
    {
        "latLng": {
            "lat": 50.9518466,
            "lng": 6.8956081
        }
    },
    {
        "latLng": {
            "lat": 50.9449884,
            "lng": 6.8308029
        }
    },
    {
        "latLng": {
            "lat": 53.111402,
            "lng": 8.747718
        }
    }
]
$.post("https://open.mapquestapi.com/directions/v2/routematrix?key=Mvag2SVgKEGvHMr4OwDh5wPuGakEk3ht", "json=" + JSON.stringify({locations}),"json").done(function(response) {
    console.log(response); // its ok, but options like units are not parsed
});

以上是关于javascript 使用免费增值API在地图上获取两点的getDistance的主要内容,如果未能解决你的问题,请参考以下文章