Go Premium for a chance to win a PS4. Enter to Win


Call MapQuest API

Posted on 2013-04-09
Medium Priority
Last Modified: 2015-04-09
Need to call MapQuest Geocoding API and get the distance between 2 locations?
Question by:triplebd69
  • 2
LVL 16

Accepted Solution

Rose Babu earned 1500 total points
ID: 39064923
Here is the javascript MapQuest API to get the direction


are you looking for a direction map or the just value between two location?

also here is a webservice for your need


this page has all the details about the webservice.

hope this will help you...

Author Comment

ID: 39066550
I have looked at this, but calling it via my C# code and parsing the XML is my issue?
LVL 16

Expert Comment

by:Rose Babu
ID: 39072712
what are all the Common URL Parameters you using in your c# code? is the outFormat xml or json?

can you give me your sample url without key value. also what error you are getting while parsing the response?

Expert Comment

ID: 40716121
Here is some php code that will do the job if that helps?

      function distance($lat1, $lon1, $lat2, $lon2, $unit) {
        $theta = $lon1 - $lon2;
        $dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) +  cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
        $dist = acos($dist);
        $dist = rad2deg($dist);
        $miles = $dist * 60 * 1.1515;
        $unit = strtoupper($unit);
        if ($unit == "K") {
          return ($miles * 1.609344);
        else if ($unit == "N") {
            return ($miles * 0.8684);
        else if ($unit == "Y") {
            return ($miles * 1760);
            else {
              return $miles;
      echo distance(50.850, -0.75838, 50.850, -0.85838, "M") . " Miles<br>";
      echo intval(distance(50.840, -0.89838, 50.849, -0.89838, "Y")) . " Yards<br>";
      echo distance(53.632293, -0.89838, 53.623393, -0.89838, "K") . " Kilometers<br>";
      echo distance(50.84316, -0.89838, 50.84317, -0.89838, "N") . " Nautical Miles<br>";

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Before we dive into the marketing strategies involved with creating an effective homepage, it’s crucial that EE members know what a homepage is. In essence, a homepage is the introductory, or default page, of a website that typically highlights the …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question