views:

34

answers:

2

I have a site that I screen-scrape off GoogleMaps to get the driving distance from one point to another. It isn't heavily used (20 requests per week max), but Google's recent upgrade broke this functionality.

I used to use this:

$url = 'http://maps.google.com/maps?f=d&hl=en&saddr='.$start.'&daddr='.$finish.'&output=xml';
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $data = curl_exec ($ch); if(preg_match('!(\d+).*?.*?(\d+)[^\d]*(\d*)!si', $data, $matches))

And it would return driving distance and total time. The new version of GoogleMaps broke this functionality and I'm trying to figure out a way to deal with the new API.

A: 

You do not need to screen scrape. Instead see this SO post:

http://stackoverflow.com/questions/964241/how-to-get-walking-or-driving-distance-via-google-maps-with-php

This tells how to do using the API

Todd Moses
I did try this initially, but had issues getting the KML output with CURL. I ended up switching the application over to using Bing Maps, which can be used with php_soap.
LinuxGnut
A: 

Scraping is against terms of service, you should use the web services directions api - http://code.google.com/apis/maps/documentation/directions/

skarE