/** * Add a geocoder result * * @todo Parse result to update geocoded properties * @param Ivory\GoogleMapBundle\Model\Services\Result\GeocoderResult $result */ public function addResult(GeocoderResult $result) { if (is_null($this->latitude)) { $this->latitude = $result->getGeometry()->getLocation()->getLatitude(); $this->longitude = $result->getGeometry()->getLocation()->getLongitude(); foreach ($result->getAddressComponents() as $addressComponent) { foreach ($addressComponent->getTypes() as $type) { switch ($type) { case 'postal_code': $this->zipcode = $addressComponent->getLongName(); break; case 'locality': $this->city = $addressComponent->getLongName(); break; case 'administrative_area_level_1': $this->region = $addressComponent->getLongName(); break; case 'country': $this->country = $addressComponent->getLongName(); break; default: break; } } } } $this->results[] = $result; }
/** * Checks the types getter & setter */ public function testTypes() { self::$geocoderResult->setTypes(array('type_1', 'type_2')); $this->assertEquals(self::$geocoderResult->getTypes(), array('type_1', 'type_2')); }