Optimized Route API - I only need the LocationSequence of the Json response

14 posts / 0 new
Last post
Optimized Route API - I only need the LocationSequence of the Json response

Hi, brilliant API by the way. This is with regards to the Optimized Route API where I am supplying around 25 locations. But I was wondering whether the JSON response can be filtered so I don't receive data that I don't require, so perhaps this may speed up the API call?

For instance I don't need directions on how to go from one place to another, rather the LocationSequence is sufficient for my needs. 

Thanks :)

You can use narrativeType
You can use narrativeType=none and don't set any of the shape parameters so you don't get narrative or shape. Otherwise, the rest of the data comes back regardless.

Ok Brian, be so kind and help

Ok Brian, be so kind and help me:

Doing this request
this happens:
I receive Narrative even its set to none
I don't receive Shape/Shapepoints, even i ask for it
Even it is set to Bicycle i can see 'hasHighways' true

Using the same String (having locations) but requesting route only I also don't receive Shapepoints.
Using from / to (so only 2 locations) i receive what i need on both requests (does not make sense on optimizedroute and narrative is still inside)

What I'm doing wrong?


I am a step further and after

I am a step further and after reading a lot i figured out to have the options in the json. So sthis is my request, but still no shapes... Is my json string as it have to be?

&json={options:{outFormat:'json', shapeFormat:'raw', generalize:1, routeType:'bicycle', cyclingRoadFactor:2, timeType:1, shapeFormat:'raw', fullShape:'true',  generalize:0, locale:'de_DE', unit:'k', drivingStyle:2, doReverseGeocode:'false', narrativeType:'none' },locations:[{latLng:{lat:46.211438,lng:6.148567}},{latLng:{lat:45.958549,lng:5.837517}},{latLng:{lat:45.640808,lng:5.627060}},{latLng:{lat:45.326746,lng:5.570755}}]}

Okay, this String is working:

Okay, this String is working:

json={locations:[{latLng:{lat:46.211438,lng:6.148567}},{latLng:{lat:45.958549,lng:5.837517}},{latLng:{lat:45.640808,lng:5.627060}},{latLng:{lat:45.326746,lng:5.570755}}],options:{outFormat:'json',generalize:1,routeType:'bicycle',cyclingRoadFactor:2,locale:'de_DE',unit:'k',drivingStyle:2,narrativeType:'none',fullShape=true }}

Look at Options: all options missing here prevent from a successful request ( like   doReverseGeocode='false') and ends up with Unable to calculate route.



The last post looks good. Are
The last post looks good. Are you getting everything you need now?

I receive too much ;)

I receive too much ;)

Would be nice when parameters would work to just receive Shape and locationSequence .
All the legs, reversegeo and instructions blow up response time & size and sure your server would love it.

Make sure doReverseGeocode is
Make sure doReverseGeocode is set to false (then it will just return the provided location string) and narrativeType is set to none (so no narrative text is returned). But the route and optimized route are intended to return all of the information. routematrix returns only time and distance and routeshape only returns shape. Thanks for the suggestion.

All is set as you suggest:

All is set as you suggest:
But I still receive the legs containing all maneuvers including the links to the manmaps.

This is the complete JSON request:


Here is the result (a part of it)

What can i do more/better to shrink the response?

At this time, that's about it
At this time, that's about it. All of that other stuff will be returned regardless of options. The route shape could be generalized to fit the application needs. Otherwise, that's as small as the response gets. But your suggestion to limit response objects has been forwarded to the team for consideration in a future release. So far it's received a warm welcome.

I just wanted to mention I

I just wanted to mention I found this post very helpful for two reasons: all I need is the LocationSequence, and I now know what the complete JSON request looks like.  No where in the documentation did it have this information, and I was ready to give up until I read this post.  The documentation gave an abstract example, but not a "real lie" example like this post has.

One question: is it possible to use more than 25 locations somehow, maybe with a different pricing plan?  Or is it forever limited to 25 locations?  Thanks!



Optimized Route limits
The limit of 25 locations per optimized route request applies to all pricing plans.  It is a performance issue with the API and not a feature that can be purchased at increased limits. Thanks!


Could please anyone tell me why when trying to get an optimized route is always returning "locationSequence" values ordered exactly the way I typed the locations in the string request ? What are proper call parameters? 

If the locations are already
If the locations are already in order, then that's the expected response. If you suspect it's wrong, post an example and we'll take a look.