Skip to content

Commit

Permalink
Directions Service to use optimize:true
Browse files Browse the repository at this point in the history
Directions service to optimize the provided route by rearranging the waypoints in a more efficient order, using optimize:true

$d = \GoogleMaps::load('directions')
->setParam([
'origin' => 'Sao Paulo, SP',
'destination' => 'Sao Paulo, SP',
'mode' => 'driving',
'waypoints' => ['optimize:true','Rua Indico, Sao Bernardo do Campo,SP', 'Santos,SP', 'Rua Aurora, Sao Bernardo do Campo,SP', 'Santos,SP', 'Sorocaba,SP'],
#'optimizeWaypoints' => 'optimize:true',
'units' => 'metric',
'region' => 'BR',
'departure_time' => 'now',
])
->get();
  • Loading branch information
alexpechkarev authored Aug 29, 2017
1 parent d82a7be commit 6b413c7
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/Parameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,18 @@ protected static function joinParam( $param = [], $join = '=', $glue = '&', $use
}
}

return !is_null( $allParam )
? implode($glue, str_replace(['%252C'],[','],$allParam) )
:'';

// return !is_null( self::$urlParam)
// ? implode($glue, str_replace(['%252C'],[','],self::$urlParam) )
// :'';
// no parameters given
if( is_null( $allParam ) ) {
return '';
}

// replace special characters
$allParam = str_replace(['%252C'], [','], $allParam);
$allParam = str_replace(['%3A'], [':'], $allParam);
$allParam = str_replace(['%7C'], ['|'], $allParam);

return implode($glue, $allParam );

}
/***/

Expand Down

0 comments on commit 6b413c7

Please sign in to comment.