Solved

Call MapQuest API

Posted on 2013-04-09
4
1,263 Views
Last Modified: 2015-04-09
Need to call MapQuest Geocoding API and get the distance between 2 locations?
0
Comment
Question by:triplebd69
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 16

Accepted Solution

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

http://developer.mapquest.com/web/documentation/open-sdk/javascript/v7.0/routing#needGeocoding

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

also here is a webservice for your need

http://www.mapquestapi.com/directions/

this page has all the details about the webservice.

hope this will help you...
0
 

Author Comment

by:triplebd69
ID: 39066550
I have looked at this, but calling it via my C# code and parsing the XML is my issue?
0
 
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?
0
 

Expert Comment

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

<?php
      
      
      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>";
      
      ?>
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

To properly understand GitHub, let’s divide it into two words ‘Git’ and ‘Hub’. Git is basically a ‘Distribution Version Control’ (DVC) and ‘Source Code Management’ (SCM) system widely used by software programmers while Hub means the efficient centre…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

726 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