[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

07/08/2008 at 05:31PM PDT, ID: 23548760
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.1

Using Google Maps API to determine the driving distance between two locations

Asked by Ray_Paseur in Extensible Markup Language (XML), JavaScript, PHP Scripting Language

Tags: Google Maps API, XHTML, XML

Building on this question:
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_23531323.html

Visit this page and you will see that Google says the driving distance is 237 miles
http://maps.google.com/maps?f=d&hl=en&geocode=&saddr=20016&daddr=15222&sll=39.693615,-78.54249&sspn=1.608247,3.633728&ie=UTF8&z=9

If you use the code snippet, Google says the driving distance is 245 miles.  You will need a Google API key to test it out.  Link here: http://code.google.com/apis/maps/signup.html

Those two answers are pretty close, and in fact, either answer is OK.  The central issue is getting the answer in a way that is programatically useful.

I want to know how to get step-wise driving distances from Google in a way that can be parsed in a PHP script.  If there is an HTTP solution that calls Google and returns a CSV or an XML string that would be ideal.  If you can show me the PHP code to "scrape" the answer out of the script below, that would be OK, too.

Thanks for your help,
Ray
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<link href="/style.css" rel="stylesheet" type="text/css" />
<title>Miles to ... using Maps API</title>
<script type="text/javascript" src="http://www.google.com/jsapi?key=[your Google API Key]"></script>
<script type="text/javascript">
//<![CDATA[
google.load("maps", "2");
var gdir;
function load() {
        if (GBrowserIsCompatible()) {
                gdir = new google.maps.Directions();
                google.maps.Event.addListener(gdir, "load", handleLoad);
                gdir.load("from: Washington, DC to: Pittsburgh, PA", {getSteps: true});
        }
}
function handleLoad() {
        document.getElementById("totalMiles").innerHTML = gdir.getDistance().html;
}
window.onload = load;
window.onunload = google.maps.Unload;
//]]>
</script>
</head>
 
<body>
<h3>Miles to ... </h3>
 
<div id="totalMiles"></div>
 
</body>
</html>
[+][-]07/08/08 11:24 PM, ID: 21960989

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Extensible Markup Language (XML), JavaScript, PHP Scripting Language
Tags: Google Maps API, XHTML, XML
Sign Up Now!
Solution Provided By: fibo
Participating Experts: 4
Solution Grade: A
 
 
[+][-]07/09/08 08:15 PM, ID: 21970205

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/10/08 05:33 AM, ID: 21972606

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/10/08 11:45 AM, ID: 21976290

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/10/08 12:04 PM, ID: 21976441

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/10/08 03:01 PM, ID: 21977765

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07/10/08 03:45 PM, ID: 21978021

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/10/08 03:59 PM, ID: 21978101

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/10/08 06:07 PM, ID: 21979131

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-91 / EE_QW_EXPERT_20070906