Skip to content

Commit 4da2b29

Browse files
author
Jordan Hall
committed
Let LatLng objects be directly converted to a string
1 parent ce8e491 commit 4da2b29

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/Objects/LatLong.php

+10
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,14 @@ public function getPoint()
6060
{
6161
return new Point($this->lat, $this->long);
6262
}
63+
64+
/**
65+
* Convert LatLong to 'latitude,longitude' string format.
66+
*
67+
* @return string
68+
*/
69+
public function __toString()
70+
{
71+
return $this->lat.','.$this->long;
72+
}
6373
}

src/Objects/SimpleGoogleMaps.php

-8
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,6 @@ public function reverseGeocode(LatLong $latLong)
170170
*/
171171
public function directions($from, $to, $travelMode = TravelMode::DRIVING)
172172
{
173-
if (is_object($from) && get_class($from) === LatLong::class) {
174-
$from = $from->lat.','.$from->long;
175-
}
176-
177-
if (is_object($to) && get_class($to) === LatLong::class) {
178-
$to = $to->lat.','.$to->long;
179-
}
180-
181173
$queryUrl = $this->authObject->applyToUrl(
182174
$this->baseUrl.'directions/json?origin='.urlencode($from).
183175
'&destination='.urlencode($to).'&mode='.$travelMode

0 commit comments

Comments
 (0)