presiannedyalkov
3/22/2019 - 11:52 AM

getDistance for two points on map with freemium API

// 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
});