Can't get back "shape"

6 posts / 0 new
Last post
spifftek
Can't get back "shape"

For some reason, mapquest won't give me the direction shape. 

 

  1. Request URL:

    http://open.mapquestapi.com/directions/v2/optimizedroute?&callback=jQuer...

The response preview is:

  1. info: {copyright: {text: "© 2015 MapQuest, Inc.", imageUrl: "http://api.mqcdn.com/res/mqlogo.gif",…},…}
  2. route: {hasTollRoad: true, computedWaypoints: [], fuelUsed: 30.01, hasUnpaved: false, hasHighway: true,…}
    1. boundingBox: {ul: {lng: -100.534744, lat: 39.828163}, lr: {lng: -89.861976, lat: 38.30516}}
    2. computedWaypoints: []
    3. distance: 689.4151
    4. formattedTime: "10:39:30"
    5. fuelUsed: 30.01
    6. hasCountryCross: false
    7. hasFerry: false
    8. hasHighway: true
    9. hasSeasonalClosure: false
    10. hasTollRoad: true
    11. hasUnpaved: false
    12. legs: [{hasTollRoad: false, index: 0, roadGradeStrategy: [[]], hasHighway: true, hasUnpaved: false,…},…]
    13. locationSequence: [0, 1, 2, 3, 4]
    14. locations: [,…]
    15. options: {mustAvoidLinkIds: [], drivingStyle: 2, countryBoundaryDisplay: true, generalize: -1,…}
    16. realTime: -1
    17. routeError: {message: "", errorCode: -400}
    18. sessionId: "56223028-01a3-0007-02b7-4f6c-00163ec01eda"
    19. time: 38370

 What am I doing wrong?


MQBrianCoakley
Two things: First, when using
Two things: First, when using json input, make sure to include the options in the json, not the kvp. Second, make sure to set the route shape and generalization parameters. I added this to your json and got the route shape.   ,options:{shapeFormat:raw,generalize:1}

spifftek
That worked great, except

That worked great, except that dragging no longer works.  You can drag the markers, but the route doesn't update and neither does the direction print.


MQBrianCoakley
Is there a url where we can
Is there a url where we can see this happening?

spifftek
JSFiddle

I can't expose my local server at the moment, but here is a demo.  http://jsfiddle.net/onp9gmay/12/

 


MQBrianCoakley
Ok, I didn't realize the you
Ok, I didn't realize the you were using the Leaflet toolkit and drag routing. Changing the shape format breaks the drag route.    The route plug in makes 2 requests: one for the route and another for the route shape. Use the route shape response to get the shape points.