src/Dlin/Geocoder/Geocoding/GoogleGeocoding.php
private function _parseComponent($components)
    {

        $address = new GeoAddress();
        $address->geoCoding = $this->name;
        $streetNumber = '';
        $routeName = '';

        foreach ($components as $component) {
            if (isset($component['types'])) {
                if (in_array('street_number', $component['types'])) {
                    $streetNumber = $component['short_name'];
                }

                if (in_array('route', $component['types'])) {
                    $routeName = $component['short_name'];
                }

                if (in_array('administrative_area_level_1', $component['types'])) {
                    $address->state = $component['short_name'];
                }

                if (in_array('locality', $component['types'])) {
                    $address->suburb = $component['short_name'];
                }

                if (in_array('postal_code', $component['types'])) {
                    $address->postcode = $component['short_name'];
                }

                if (in_array('country', $component['types'])) {
                    $address->country = $component['long_name'];
                }
            }

        }



        if ($routeName || $streetNumber) {
            $address->addressLine1 = trim($streetNumber . ' ' . $routeName);
        }



        return $address;
    }
private function _parseComponent($components)
    {

        $address = new GeoAddress();
        $address->geoCoding = $this->name;
        $streetNumber = '';
        $routeName = '';

        foreach ($components as $component) {
            if (isset($component['types'])) {
                if (in_array('street_number', $component['types'])) {
                    $streetNumber = $component['short_name'];
                }

                if (in_array('route', $component['types'])) {
                    $routeName = $component['short_name'];
                }

                if (in_array('administrative_area_level_1', $component['types'])) {
                    $address->state = $component['short_name'];
                }

                if (in_array('locality', $component['types'])) {
                    $address->suburb = $component['short_name'];
                }

                if (in_array('postal_code', $component['types'])) {
                    $address->postcode = $component['short_name'];
                }

                if (in_array('country', $component['types'])) {
                    $address->country = $component['long_name'];
                }
            }

        }



        if ($routeName || $streetNumber) {
            $address->addressLine1 = trim($streetNumber . ' ' . $routeName);
        }



        return $address;
    }
private function _parseComponent ( $ components ) { $ address = new GeoAddress ( ) ; $ address -> geoCoding = $ this -> name ; $ streetNumber = '' ; $ routeName = '' ; foreach ( $ components as $ component ) { if ( isset ( $ component [ 'types' ] ) ) { if ( in_array ( 'street_number' , $ component [ 'types' ] ) ) { $ streetNumber = $ component [ 'short_name' ] ; } if ( in_array ( 'route' , $ component [ 'types' ] ) ) { $ routeName = $ component [ 'short_name' ] ; } if ( in_array ( 'administrative_area_level_1' , $ component [ 'types' ] ) ) { $ address -> state = $ component [ 'short_name' ] ; } if ( in_array ( 'locality' , $ component [ 'types' ] ) ) { $ address -> suburb = $ component [ 'short_name' ] ; } if ( in_array ( 'postal_code' , $ component [ 'types' ] ) ) { $ address -> postcode = $ component [ 'short_name' ] ; } if ( in_array ( 'country' , $ component [ 'types' ] ) ) { $ address -> country = $ component [ 'long_name' ] ; } } } if ( $ routeName || $ streetNumber ) { $ address -> addressLine1 = trim ( $ streetNumber . ' ' . $ routeName ) ; } return $ address ; }
This function use to parse the return components from google geocoding api
@param $components
@return GeoAddress
This function use to parse the return components from google geocoding api