Merge pull request #3 from rasmusbe/master

Added support for radarsearch and place details requests
This commit is contained in:
Joshua John Sherman 2014-01-28 11:28:50 -08:00
commit 22d595da1f
2 changed files with 52 additions and 0 deletions

View file

@ -17,6 +17,8 @@ class GooglePlaces
public $rankby = 'prominence'; public $rankby = 'prominence';
public $sensor = false; public $sensor = false;
public $types = null; public $types = null;
public $reference = null;
public $opennow = null;
public function __construct($key) public function __construct($key)
{ {
@ -139,6 +141,40 @@ class GooglePlaces
} }
} }
break;
case 'radarsearch':
if (!isset($parameters['location']))
{
throw new Exception('You must specify a location before calling nearbysearch().');
}
elseif (!isset($parameters['radius']))
{
throw new Exception('You must specify a radius.');
}
elseif (empty($parameters['keyword']) && empty($parameters['name']) && empty($parameters['types']))
{
throw new Exception('A Radar Search request must include at least one of keyword, name, or types.');
}
if (isset($parameters['rankby']))
{
unset($parameters['rankby']);
}
break;
case 'details':
if (!isset($parameters['reference']))
{
throw new Exception('You must specify a reference before calling details().');
}
if (isset($parameters['rankby']))
{
unset($parameters['rankby']);
}
break; break;
} }
} }

View file

@ -46,6 +46,22 @@ $google_places->pageToken = $results['next_page_token'];
$page2_results = $google_places->nearbySearch(); $page2_results = $google_places->nearbySearch();
``` ```
### Radar search
```php
$google_places->location = array(-33.86820, 151.1945860);
$google_places->radius = 800;
$google_places->types = 'restaurant'; // Requires keyword, name or types
$results = $google_places->radarSearch();
```
### Place details
```php
$google_places->reference = '#reference#'; // Reference from search results
$details = $google_places->details();
```
The Fututre The Fututre
----------- -----------