add latitude longitude collection in routing

2 posts / 0 new
Last post
add latitude longitude collection in routing


I have just started using MapQuest. I am using Javascript API. Map is showing fine. While creating route i need to get lat and lng from server. I am using jquery ajax. How i can pass latitudes and longitudes as collection. 

Here is my code:


 MQA.EventUtil.observe(window, 'load', function () {

        // create an object for options
        var options = {
            elt: document.getElementById('map'),       // ID of map element on page
            zoom: 10,                                  // initial zoom level of the map
            latLng: { lat: 41.881832, lng: -87.623177 },  // center of map in latitude/longitude
            mtype: 'map',                              // map type (map, sat, hyb); defaults to map
            bestFitMargin: 0,                          // margin offset from map viewport when applying a bestfit on shapes
            zoomOnDoubleClick: true                    // enable map to be zoomed in when double-clicking

        // construct an instance of MQA.TileMap with the options object = new MQA.TileMap(options);

            type: "Get",
            url: '@Url.Action("Action", "Controller")',
             contentType: "application/json; charset=utf-8",
             data: {},
             dataType: "json",
             success: function (data) {
                 var pois = [];
                 $.each(data, function (index, value) {
                     if ( != null && value.lng != null) {
                         var start = new MQA.Poi({ lat:, lng: value.lng });
                 MQA.withModule('new-route', function () {


                         request: {
                             locations: [pois]   // If i add hard coded lat and lng then it works fine but not in this case.



Thanks in advance

What error messages are you
What error messages are you getting?   If you put the pois directly on the map do they show up as expected?