Skip to content

Add support for formatted address #558

Closed

Description

@Nyholm

Google support returning formatted addresses. We should somehow support this.

Activity

  1. added this to the 4.0.0 milestone on Dec 22, 2016
  2. fyrye commented on Feb 6, 2017

    @fyrye

    One suggestion to this would be to also allow the retrieval of responses from the providers, rather than just extracting the information in the executeQuery method.

    Then a user would be able to extend a Provider object and instead of being forced to override the executeQuery method they could parse the response as desired with their own method.

    For example:

    $adapter  = new \Http\Adapter\Guzzle6\Client();
    $geocoder = new \Geocoder\Provider\GoogleMaps($adapter);
    
    $geocoder->geocode(...);
    $jsonResponse = $geocoder->getRepsonse(); //formatted address is available here
    public function geocode($address)
    {
       $query = $address;
       //...
       return $this->parseData($this->executeQuery($query));
    }
    
    public function getResponse()
    {
        return $this->response;
    }
    
    private function parseData($content)
    {
        //...
       return $this->resultResults($results);
    }
    
    protected function executeQuery($query)
    {
        $query = $this->buildQuery($query);
        if (!$this->response = json_encode((string) $this->getAdapter()->get($query)->getBody())) {
            throw new NoResult(sprintf('Could not execute query "%s".', $query));
        }
        //... move parsing of data out of executeQuery
    
        return $this->response;
    }
  3. Nyholm commented on May 30, 2017

    @Nyholm
    MemberAuthor

    Closed by #655

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions