PHP Create Google Map Directions Link


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function googleMapLink($to, $from) {
  2. $destinationAddy = '&daddr='.urlencode($to->getAddress().' '.$to->getCity().' '.$to->getState());
  3.  
  4. if($from) {
  5. $startAddy = '&saddr='.urlencode($from->getAddress().' '.$from->getCity().' '.$from->getState());
  6. } else {
  7. $startAddy = '&saddr=';
  8. }
  9.  
  10. return htmlentities("http://maps.google.com/maps?f=q&hl=en&{$startAddy}{$destinationAddy}");
  11. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.