简体   繁体   English

Google Places API最近的地方电话号码

[英]Google Places API nearest place phone number

May I know how to get phone number from the google places API? 我可以知道如何从Google Places API获取电话号码吗?

I need to display name of the place including the phone number. 我需要显示地方的名称,包括电话号码。 Now I am able to get the name, but not the phone number. 现在我可以得到名字,但不是电话号码。

myLatlng = new google.maps.LatLng(30.731212, 76.830220);        

var mapOptions = {
            center: myLatlng,
            zoom: 12,
        };

        map = new google.maps.Map(document.getElementById("map"), mapOptions);      


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

var request = { 
                    location: myLatlng,
                    radius: '20000',
                    types: ['atm' , 'hospital',  'resturant', 'accounting', 'airport', 'food', 'bank', 'park']
                  };  

    function callback(results, status) {
              if (status == google.maps.places.PlacesServiceStatus.OK) {
                for (var i = 0; i < results.length; i++) {
                  var place = results[i];
console.log(place);
                   console.log(place.phone_number);
                }
              }
            }

In Place object you got every place details. 在Place对象中,您获得了每个地方的细节。 Check you console and if phone number exists then it will return in place.phone or place.phone_number . 检查您的控制台,如果存在电话号码,它将返回到位.phoneplace.phone_number Please check the actual key for phone number. 请检查电话号码的实际密钥。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM