PHP Classes

PHP Google Driving Directions: Get driving directions using Google Maps API

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 56%Total: 1,931 All time: 2,042 This week: 114Up
Version License PHP version Categories
google-directions 1.0GNU General Publi...5.2.0PHP 5, Web services, Geography
Description 

Author

This class can get driving directions using Google Maps API.

It takes the addresses of two locations and sends a HTTP request to Google Maps API to retrieve driving directions to go from one location to the other.

The class may also retrieve the driving directions drawn in an image of the map that includes both locations.

The map image is stored in a given file in either JPEG or PNG formats. The scale level of the map is also configurable.

Innovation Award
PHP Programming Innovation award winner
May 2013
Winner


Prize: One copy of the Zend Studio
The Google Maps API provides several useful services besides showing maps, like for instance providing driving directions to go from one location to another.

This class provides a PHP interface to obtain driving directions between two locations using the Google Maps API.

Manuel Lemos
Picture of Marcus Brasizza
  Performance   Level  
Name: Marcus Brasizza <contact>
Classes: 6 packages by
Country: Brazil Brazil
Age: 37
All time rank: 63646 in Brazil Brazil
Week rank: 312 Up26 in Brazil Brazil Up
Innovation award
Innovation award
Nominee: 3x

Winner: 1x

Recommendations

Traffic simulation with Maps
Perform traffic simulation with Google Maps

Example

<?php
include('googleApiClass.php');
$google = new googleApiClass();

$google->setFromAddress('England');
$google->setToAddress('France');
$google->setLanguage('us');
$google->setImageOutput('png');
$google->setZoom(14);
$google->setScale('1');
try{
   
$pathImg = '/tmp/mapMe.png';
   
$google->findAddress()->withImage(5,$pathImg);
   
    echo
"From: ". $google->getFromAddress().'<br>';
    echo
"To: ". $google->getToAddress().'<br>';
    echo
"Distance: ".($google->getDistance()).' meters<br>';
    echo
"Time: ".($google->getTime()).' seconds<br>';
    echo
" {$google->getCountSteps()} steps between from and to address<br>";
    echo
"<hr><strong>Steps</strong>";
    echo
"<pre>";
   
print_r($google->getInstructions());
    echo
"</pre>";
    if(!
$google->getImgBuffer()){
        echo
"No image was requested";
    }else{
        echo
"Followed Image <br>";
        echo
"Scale: ".$google->getScale().'<br>';
        echo
"Center: ".$google->getCenterStep().'<br>';
        echo
"Zoom: ".$google->getZoom().'<br>';
       
        echo
"<img src='showimage.php?path={$pathImg}'><br>";
               
    }
   
   
}catch(
Exception $e ){
 echo
$e->getMessage();
}

?>


Screenshots  
  • oututmap
  Files folder image Files  
File Role Description
Plain text file googleApiClass.php Class the api class to connect with de google maps
Accessible without login Plain text file showimage.php Aux. Auxiliar data to show the image created with the google api
Accessible without login Plain text file test.php Example Test script

 Version Control Unique User Downloads Download Rankings  
 0%
Total:1,931
This week:0
All time:2,042
This week:114Up
User Ratings User Comments (1)
 All time
Utility:81%StarStarStarStarStar
Consistency:81%StarStarStarStarStar
Documentation:-
Examples:75%StarStarStarStar
Tests:-
Videos:-
Overall:56%StarStarStar
Rank:1812
 
Pointing google map was too dark.
10 years ago (Arun Signit)
70%StarStarStarStar