-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from webrealisierung-ch/develop
Typos and add properties
- Loading branch information
Showing
1 changed file
with
13 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
use Psr\Log\LoggerInterface; | ||
|
||
/** | ||
* A class to calculate the geo position form a given adress, city, place or country over the google geocode api. | ||
* A class to calculate the geo position form a given address, city, place or country over the google geocode api. | ||
* Requires a active google maps api key | ||
* | ||
* @author Daniel Steuri <[email protected]> | ||
|
@@ -26,7 +26,7 @@ class Geocoder | |
public $lat; | ||
public $coords; | ||
|
||
public $formattedAdress; | ||
public $formattedAddress; | ||
public $placeId; | ||
public $types; | ||
public $status; | ||
|
@@ -43,15 +43,15 @@ public function __construct(LoggerInterface $logger) | |
} | ||
|
||
/** | ||
* @param $adress string | ||
* @param $address string | ||
* @param $country string | ||
* @param $apiKey string | ||
* @return bool|mixed|null | ||
*/ | ||
public function calculate($adress,$country,$apiKey) | ||
public function calculate($address,$country,$apiKey) | ||
{ | ||
$apiKey = urlencode($apiKey); | ||
$adress = urlencode($adress); | ||
$address = urlencode($address); | ||
$country = urlencode($country); | ||
|
||
if (!function_exists('curl_init')) { | ||
|
@@ -63,7 +63,7 @@ public function calculate($adress,$country,$apiKey) | |
|
||
$urlParams = sprintf( | ||
'https://maps.googleapis.com/maps/api/geocode/json?address=%s+%s&key=%s', | ||
$adress, $country, $apiKey | ||
$address, $country, $apiKey | ||
); | ||
|
||
$ch = curl_init($urlParams); | ||
|
@@ -88,13 +88,17 @@ private function checkResponseStatus($geocoderResponse){ | |
$this->lat = $geocoderResponse->results[0]->geometry->location->lat; | ||
$this->lng = $geocoderResponse->results[0]->geometry->location->lng; | ||
$this->coords=$this->lat.",".$this->lng; | ||
$this->logger->info('The coordinates are correcty calculated with the specified adress.', array( | ||
$this->formattedAddress=$geocoderResponse->results[0]->formatted_address; | ||
$this->placeId=$geocoderResponse->results[0]->place_id; | ||
$this->types=$geocoderResponse->results[0]->types; | ||
$this->status=$geocoderResponse->status; | ||
$this->logger->info('The coordinates are correcty calculated with the specified address.', array( | ||
'contao' => new ContaoContext(__CLASS__.'::'.__FUNCTION__, ContaoContext::GENERAL | ||
))); | ||
break; | ||
case "ZERO_RESULTS": | ||
$this->status=$geocoderResponse->status; | ||
$this->logger->info('The coordinates could not be calculated with the specified adress.', array( | ||
$this->logger->info('The coordinates could not be calculated with the specified address.', array( | ||
'contao' => new ContaoContext(__CLASS__.'::'.__FUNCTION__, ContaoContext::GENERAL | ||
))); | ||
break; | ||
|
@@ -112,7 +116,7 @@ private function checkResponseStatus($geocoderResponse){ | |
break; | ||
case "INVALID_REQUEST": | ||
$this->status=$geocoderResponse->status; | ||
$this->logger->info('Adress, Component or LatLng is missing in the request', array( | ||
$this->logger->info('Address, Component or LatLng is missing in the request', array( | ||
'contao' => new ContaoContext(__CLASS__.'::'.__FUNCTION__, TL_GENERAL | ||
))); | ||
break; | ||
|