Reputation: 3351
I'm writing a code to get the near by locations as prompted by the user using Node.js and making a call to Google's places API. and the call is as below.
https://maps.googleapis.com/maps/api/place/textsearch/json?query=garage+near+corner+of+
fifth+avenue+NY&key=myApiKey
basically here I'm searching for the Garage near the 5th avenue New York. and the response that I get is as below.
{
"html_attributions": [],
"next_page_token": "CqQCHgEAAKUUxRRzEF_vLKTGE5CLg-kBW7K8ot040l4zcsNHEByHpvjrhZZVOWcyCiPBbtErrX9QZNQ9dZQXCaxynnaJonFjF23_PPhWAmIfIRbY40E4gFioA5o4Gm3_OjkOicROypQQlArqaf2ub6vGoMwDKU1eP8m6SFmiMwm1cS_mghR0IWJ2Q9mH5jqpPtWJd2ENX3VCrDPeoOfhaxHAg3DIG7-eh7WYMlT9r6KAERCok-fXnjI49QVrezZYK52aCY3qeLSPLeXonrE2a79jfEdV1EhpBvb4fV2SB2oysCc_xK_Kv3FW6-Ir3WK2jXslrfRvFk7sIRxtgqAlZ2xCZ43oi7DeTl5733S5j4pbFZQHgsg9grLApa_H_wTN2xN1K9UsEhIQOf7B6Gnh668FPRTZe4X78BoUOMt8UiiVZR-YDJDb5AwyME7yYuY",
"results": [
{
"formatted_address": "39 W 23rd St, New York, NY 10010, United States",
"geometry": {
"location": {
"lat": 40.742537,
"lng": -73.99092399999999
},
"viewport": {
"northeast": {
"lat": 40.7437215802915,
"lng": -73.9896989197085
},
"southwest": {
"lat": 40.7410236197085,
"lng": -73.99239688029151
}
}
},
"icon": "https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id": "b075e432a0597a31ceaf3062747999291d8d8cf7",
"name": "Park-it 23-24 Operating Corp",
"opening_hours": {
"open_now": false,
"weekday_text": []
},
"place_id": "ChIJJalOaKRZwokRNLnbupB5UrY",
"reference": "CmRSAAAA-HGHWnLtBTIkRA7MlY1sjb8jDIxJQokfHSfQ_MWcLLM7lNB_MlUOwO0TcrQO8IYbUz1_l-HiehIwZ3hvg3sHEAiV-ZYpNL11gY15gz6hQsUFFKEkkfqoo_9R1PzVBd9CEhD7AxenKMzgH0LK4lNPFC8GGhSKMjd_5UnZyA3VRJrRYaw79QcxVg",
"types": [
"parking",
"point_of_interest",
"establishment"
]
}
.
.
.
.
}
I the result received there is no phoneNumber
available. can you please let me know if I'm using the correct API to get the near by places and how can I get the phone number along with the result.
Thanks
Upvotes: 5
Views: 7819
Reputation: 32178
Currently, there is no way to get phone number from the Places API search response. In order to get a phone number you have to execute a Places details request for each individual place ID.
E.g. https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJJalOaKRZwokRNLnbupB5UrY&key=YOUR_API_KEY
The response will contain fields formatted_phone_number
and international_phone_number
...
"adr_address":"39 W 23rd St, New York, NY 10010-4295, USA",
"formatted_address":"39 W 23rd St, New York, NY 10010, USA",
"formatted_phone_number":"(212) 727-0141",
"geometry":{
"location":{
"lat":40.742537,"lng":-73.99092399999999
},
"viewport":{
"northeast":{
"lat":40.7437215802915,"lng":-73.9896989197085
},
"southwest":{
"lat":40.7410236197085,"lng":-73.99239688029151
}
}
},
"icon":"https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id":"b075e432a0597a31ceaf3062747999291d8d8cf7",
"international_phone_number":"+1 212-727-0141",
"name":"Park-it 23-24 Operating Corp",
...
I can also see that somebody tried to file a feature request for this in Google issue tracker back in 2011, however Google closed this feature request as infeasible
https://issuetracker.google.com/issues/35820573
Feel free to create a new feature request in Google issue tracker, hopefully Google may reconsider it in 2017.
Upvotes: 6