7
votes

I am having problems understanding the Google Places API. I am building an iPhone application with a nearby feature that allows the user to find restaurants located around the user's GPS. How can I obtain a Google API for this? Do I have to have one custom made how does this work? If I also wanted to create an API for points of interest how can I do that?

3

3 Answers

10
votes

There is a Google Places API for searching for nearby locations. The documentation is here: https://developers.google.com/places/documentation/search#PlaceSearchRequests

But I'm guessing you already found that. If you ask more specific questions, we can be more helpful.

7
votes

You can use Google place API , and if you want to display only specific type of places e.g restaurant in your cases you can use request object as shown in the code below

 var request = {
    location: pyrmont,
    type: ['restaurant']
  };

 infowindow = new google.maps.InfoWindow();
  places = new google.maps.places.PlacesService(map);
places.nearbySearch(request, callback);

For more details on type filteration in google place API you can check the Link on Google Developers. But nearby search taking only one type parameter, and it is only restaurants. Not food, not cafe, only restaurants, which Google API provides, if you are looking for the public catering establishments.

0
votes

First of all, the Google Paces API should be active.

function displayRestaurantAround() {
  return new Promise((resolve, reject) => {
    this.service.nearbySearch({
      location: currentUserPosition,
      radius: 5000,
      types: ['restaurant']
    }, (res) => {
      resolve(res);
    });
  });
}