I only need the miles

6 posts / 0 new
Last post
I only need the miles

I have the situation where I only need the miles that a trip would be and I don't actually need the turn-by-turn directions.  I need the miles that would be the result of turn-by-turn directions but not the directions themselves.  I am currently using the API to obtain the turn-by-turn directions and then discarding everything except the total miles.  This seems, to me, to be very inefficent to send me back a ton of bytes when all I need is a few.  

Is there an API that would just return to me the total miles?

On a related note, my usage is sky rocketing because every query I am making MapQuest is geocoding before generating the directions.  However, I am sending lat/lons in my request.  I'm not sending addresses.  I've already captured the lat/lon of every location and am only sending the lat/lons.  What am I missing?

If anyone can help, it would be most appreciated.


Mark Evanoff

Hi Mark,
Hi Mark,   Use the route matrix to get only distance and time back. There are no narratives, sign/map urls, or anything else.   Make sure to set doReverseGeocode to false if you don't need an address for your destination maneuver. This gives at least an estimated address to look for when routing to a lat/lng. It's one of the advanced routing options.   Hope that helps.

Thanks!  I've set the

Thanks!  I've set the doReverseGeocode to false (it was set to true before).  Now I'll monitor the transaction counts and, hopefully, I'll see a big drop in the number of geocode transactions.

I'll work on using the "route matrix" next.


Sounds good. Let us know if
Sounds good. Let us know if you have any other questions.

Ok... I've been running this

Ok... I've been running this new process I've developed since Monday (5/16) and it seems to be working pretty well however, I do have a problem occasionally and I am trying to figure out a) what is this problem and b) if I can't resolve it, at least be able to identify when it has occured so I can handle it more gracefully.

I am doing this in ASP (yes... Classic ASP, not .NET).  I have the API to MapQuest working fine except on, what seems to be rare occasions.  Here is the HTML that is build by the process that fails:


If I take this html and paste it directly into a browser it works fine.  It is only when I try and use this in ASP that I have a problem.  But keep in mind, we have now successfully used this ASP process thousands of times since Monday so it appears to be something particular about this precise HTML.  So far I've had 2 instances where the API to MapQuest has failed to work correctly.

This is the actual code to call MapQuest inside the ASP program:

    Set o = CreateObject("MSXML2.XMLHTTP")
    o.open "GET", pv_route, False

The program will fail on the "pv_start=inStr(o.responseText,"statuscode")" line, presumely because nothing was returned.

So... my questions are:  1)  can you figure out why it would fail and 2) should it sometimes fail, what is it I could interrograte to determine it has failed so I can exit gracefully without having th program just crash?

Any help would be most appreciated.

Thank you,

Mark Evanoff

There is an info.statusCode
There is an info.statusCode and info.messages node that will give details about any known failure. You can see what the status codes mean here.   Without having a failing request to recreate the issue, the only thing that I can guess is that the request timed out. If a route has many locations it may take several seconds to respond and if the application has a short enough timeout then it may not receive a response in time.