Git Product home page Git Product logo

google-places's Introduction

G'Day ๐Ÿ‘‹

I am a Nomadic open source advocate. I love indie game development, electronics, Linux and being underwater amongst other things.

My Interests

google-places's People

Contributors

angelxmoreno avatar anthony-mills avatar arsey avatar boo1ean avatar clicman avatar crxgames avatar david-bascom avatar enobrev avatar janpapenbrock avatar shivamdixit avatar simpod avatar truongnguyen1912 avatar wnateg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

google-places's Issues

Paging

Google places api now (not sure how recent) offers paging for up to 3 pages. Do you have any interest in adding that to your api?

Use release function

Hi there,

is it possible that you create tags/releases for your repo. It would be awesome, so composer can download (instead of clone) the package.

googlePlaces::_formatResults() does not format the results correctly

googlePlaces::_formatResults() line 193, initializes $address_street_number, $address_street_name, $address_state etc to empty each time in for loop. This causes all the values to be empty if they are not present in last loop of foreach even though they are found in previously. This is resulting to empty value of all these strings in most of the results.

Can not set a RankBy parameter

In the Docs:

rankby โ€” Specifies the order in which results are listed. Possible values are:
1. prominence (default). This option sorts results based on their importance. Ranking will favor prominent places within the specified area. Prominence can be affected by a Place's ranking in Google's index, the number of check-ins from your application, global popularity, and other factors.
2.distance. This option sorts results in ascending order by their distance from the specified location. Ranking results by distance will set a fixed search radius of 50km. One or more of keyword, name, or types is required.

I'll have a PR for it soon

Why echo?

Been using this class for a bit now... why does the _curlCall method echo out the post opts? Is this necessary?

google place detail issue

I have the follow code

require_once(DIR . '/../../../assets/google/googlePlaces.php');

    $apiKey       = 'xxxx';
    $googlePlaces = new GooglePlaces\googlePlaces($apiKey);
    $googlePlaces->setPlaceId('ChIJ67bX6M6w3IARpKYGn3F-LOc');

    $result = $googlePlaces->details();

and it's return empty, do you know why? can you please help?

Repeat function is not working right now

Im using this code, and I'm getting a 'Invaled Request' without errors: [results] => Array ( ) [status] => INVALID_REQUEST ) {"errors":[],"result":[]}

// Set the longitude and the latitude of the location you want to search near for places
$latitude   = '40.383333';
$longitude = '-3.716667';
$googlePlaces->setLocation($latitude . ',' . $longitude);
$googlePlaces->setTypes("parking");
$googlePlaces->setRadius(10000);
$results = $googlePlaces->Search();
// echo json_encode($results);


if (!empty($results['next_page_token'])) {
    //echo $results['next_page_token'];
    $secondSearch = $googlePlaces->repeat($results['next_page_token']);
    echo json_encode($secondSearch);
}

Does somebody know what is happening here?

Next Page Token sometimes doesn't work.

Running the next page token code to get more than 20 results doesn't work half of the time. Do I need to put a delay before calling the next pages, since Google may be limiting the number of requests.

Missing Key And Formatting Errors

Had to modify this:
protected function _formatParametersForURL() {
if (!empty($this->_address)) {
return self::ADDRESS_FIELD_NAME.'='.$this->_address .
'&'.self::COMPONENTS_FIELD_NAME.'='.$this->_components .
'&'.self::LANGUAGE_FIELD_NAME.'='.$this->_language .
'&'.self::BOUNDS_FIELD_NAME.'='.$this->_bounds .
'&'.self::REGION_FIELD_NAME.'='.$this->_region .
'&'.self::SENSOR_FIELD_NAME.'='.$this->_sensor;
}
else {
return self::LAT_LNG_FIELD_NAME.'='.$this->_latlng .
'&'.self::COMPONENTS_FIELD_NAME.'='.$this->_components .
'&'.self::LANGUAGE_FIELD_NAME.'='.$this->_language .
'&'.self::BOUNDS_FIELD_NAME.'='.$this->_bounds .
'&'.self::REGION_FIELD_NAME.'='.$this->_region .
'&'.self::SENSOR_FIELD_NAME.'='.$this->_sensor;
}

And add $URLToCall = $this->_apiUrl . '/' . $this->_outputType . '?key='.$this->_apiKey . '&' . $urlParameters; @ line 54.

Params encoding

Be careful when setting name param on searches. It's required to urlencode them in order to get the expected results; otherwise it won't work. From my point of view, it should be done inside the googlePlaces class, but I think the creator doesn't think like me.

Anyway, I'd like to thank the author for this work. It still has saved me some time.

Not an issue but could you could use

function distance($lat1, $lon1, $lat2, $lon2, $unit) {

    $theta = $lon1 - $lon2;
    $dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) +  cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
    $dist = acos($dist);
    $dist = rad2deg($dist);
    $miles = $dist * 60 * 1.1515;
    $unit = strtoupper($unit);

    if ($unit == "K") {
        return ($miles * 1.609344);
    } else if ($unit == "N") {
        return ($miles * 0.8684);
    } else {
        return substr($miles,0,3);
    }

}

Here is code that will calculate the distance between two distances if you want it.
Nice for seeing how far a place is from you

googlePlaces::_formatResults() removes next_page_token

I'll send a PR once the first PR is accepted. I should have made separate branches for individual fixes :-P

I basically added

if (isset($result['next_page_token'])) {
            $formattedResults['next_page_token'] = $result['next_page_token'];
        }

to the end of googlePlaces::_formatResults() before:

return $formattedResults;

[Google-Places---PHP-] Class google place

Hello, how are you?
Congratulations for the work, Google is class place is very good!
I wonder if it is possible to have an update in the following methods.

Method of delete: The parameter that needs to go is the parameter is of reference and is currently in the class request the place_id.

Method of Checkin: The parameter that needs to go is the parameter is of reference and also it needs to be sent via POST, the same as delete and add the method.

Abs

Add place error (Invalid Request)

Location fields must be casted to floats in order to get the expected result... It throws an Invalid Request if you send them as strings as they are.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.