Help with MapQuest routes!

35 views
Skip to first unread message

Leonardo Luís Röpke

unread,
Aug 29, 2014, 8:02:39 AM8/29/14
to leafl...@googlegroups.com
  Good day, I would like to ask your help in creating routes. In fact I can even create routes normally using MapQuest APIs, only the latitudes and longitudes are always fixed in my code. And I need to do this automatically using some variable because this route she has change when reach a certain AJAX request and return this new latitudes and longitudes.
  Here the code I'm using with fixed latitudes and longitudes:

dir = MQ.routing.directions();

dir.route({
     locations: [
        {latLng: {lat: -27.695014, lng: -54.169515}},
        {latLng: {lat: -27.688079, lng: -54.171422}},
        {latLng: {lat: -27.677383, lng: -54.169575}},
        {latLng: {lat: -27.673424, lng: -54.176956}},
        {latLng: {lat: -27.673485, lng: -54.179887}},
        {latLng: {lat: -27.678398, lng: -54.182580}},
        {latLng: {lat: -27.686335, lng: -54.186370}},
        {latLng: {lat: -27.686523, lng: -54.183735}},
        {latLng: {lat: -27.699906, lng: -54.189541}},
        {latLng: {lat: -27.706650, lng: -54.201594}},
        {latLng: {lat: -27.684245, lng: -54.126360}}
    ]
});

map.addLayer(MQ.routing.routeLayer({
    directions: dir,
    fitBounds: true
}));

  Instead here: {latLng: {lat: -27.684245, lng: -54.126360}}
  I would like to use a variable or something so I could add more latitudes and longitudes, remove or change their values.


Reply all
Reply to author
Forward
0 new messages