int(3)
Next Previous

Places API Nearby Search

Nearby Search Request is part of the Google Places API Library.

It allows searching for different types of places such as restaurants, grocery stores, etc based on the user’s current location.

HTML5 Geolocation

Get User Location using HTML5 Geolocation in the form of Latitude and Longitude.

navigator.geolocation.getCurrentPosition(
     position => {
         console.log(position.coords.latitude);
         console.log(position.coords.longitude);
     },
     error => {
         console.log(error.message);
     }
)

Nearby Search Base URL

https://maps.googleapis.com/maps/api/place/nearbysearch/
Valid Jul 9th Thu - Jul 14th Tue 2020

🔥 1086+ students enrolled!
4.85 ⭐️⭐️⭐️⭐️⭐️ (31+ ratings) BEST SELLER

94% OFF
Vue.js & Google Maps API: Build Location-Based Web Apps Like A Pro!

GET PROMO CODE

Request URL Parameter (Required)

namedescription
JSON or XMLOutput format (json recommended)

Request Query Parameters (Required)

namedescription
keyYour API Key from Google Cloud Platform. Find how to get it here.
locationThe value must be specified in the format of latitude, longitude.
radiusSpecify in meters. i.e. 5000 = 5KM
typeThis could be a restaurant, bar, etc. full list here.

Optional Query Parameters

namevaluedescription
rankbydistanceThis will sort places in ascending order by their distance. When using rankby, the radius option can’t be used.

Sample Request URL to Nearby Search

https://maps.googleapis.com/maps/api/place/nearbysearch/json?key=[YOURAPIKEY]&location=-33.8670522,151.1957362&radius=5000&type=restaurant

Nearby Search Response JSON Object

Once the request is complete, it will return a response object in a JSON format like the screenshot below and it will have 20 places inside the results array.

Get Next 20 Places

As you know, Nearby Search Request gives you only 20 results in the response object per request.

To get the next 20 results, we’ll need to add an additional query parameter called pagetoken to the URL.

And the value of this param can be found in the previous response object under the property called next_page_token like the image below.

So the sample request URL would be like this.

https://maps.googleapis.com/maps/api/place/nearbysearch/json?key=[YOURAPIKEY]&location=-33.8670522,151.1957362&radius=5000&type=restaurant&pagetoken=CqQCFQEAAKQ48fsO4kjIu

You can get the maximum of 60 places using Nearby Search Request.

Next Previous

Join Over 1000 🔥

Hey, Like What You're Reading?

JOIN to learn more about Google Maps API


Valid 9th - 14th Jul 2020
85% OFF

Vue.js & Google Maps API: Build Location-Based Web Apps Like A Pro!

🔥 1086+ students enrolled!
4.85 ⭐️⭐️⭐️⭐️⭐️ (31+ ratings)

BEST SELLER