Integration of Google Places search API in Node JS
If you want to add place search and want to display places on Google map using NodeJS then you are at the right place.
Google provides a feature of searching places based on the latitude and longitude or we can say location. Google gives Places API Requests, NearBy Search API Requests to search place information like shops, hospitals, Grocery stores, Petrol pumps, Restaurants nearby you.
Following are the key points which are required when you search for any place:
- Radius
- Location (Latitude and Longitude)
- Place’s name / Category of place’s name like Restaurant
Type of APIs and its usage
- Place Search API
- To search the list of places with respect to passed location or search string. We can search places using variety of
- categories,
- including establishments
- prominent points of interest
- geographic locations
- We can search either by geolocation and radius or search string
- API EndPoint
- Search by text
- https://maps.googleapis.com/maps/api/place/findplacefromtext/json?parameters
- Find nearbyplaces
- https://maps.googleapis.com/maps/api/place/nearbysearch/json?parameters
- Text Search Request
- https://maps.googleapis.com/maps/api/place/textsearch/json?parameters
- Place Details API
- To get the details of the single place with user reviews
- API EndPoint
- https://maps.googleapis.com/maps/api/place/details/json?parameters
- Example
- https://maps.googleapis.com/maps/api/place/details/json?place_id=ChIJN1t_tDeuEmsRUsoyG83frY4&fields=name,rating,formatted_phone_number&key=YOUR_API_KEY
- Place Photos API
- To access the photos of the places stored in Google DB
- API EndPoint
- https://maps.googleapis.com/maps/api/place/photo?parameters
- Example
- https://maps.googleapis.com/maps/api/place/photo?maxwidth=400&photoreference=CnRtAAAATLZNl354RwP_9UKbQ_5Psy40texXePv4oAlgP4qNEkdIrkyse7rPXYGd9D_Uj1rVsQdWT4oRz4QrYAJNpFX7rzqqMlZw2h2E2y5IKMUZ7ouD_SlcHxYq1yL4KbKUv3qtWgTK0A6QbGh87GB3sscrHRIQiG2RrmU_jF4tENr9wGS_YxoUSSDrYjWmrNfeEHSGSc3FyhNLlBU&key=YOUR_API_KEY
- Place AutoComplete
- To automatically show the suggestions based on the typed string or text
- API EndPoint
- https://maps.googleapis.com/maps/api/place/autocomplete/output?parameters
- Query AutoComplete
- To provide the query predicted as the user typed the string or text
- API EndPoint
- https://maps.googleapis.com/maps/api/place/queryautocomplete/output?parameters
Read more: https://tudip.com/blog-post/integration-of-google-places-search-api-in-node-js/