如何使用谷歌业务获取业务详细信息

时间:2016-10-04 09:36:50

标签: javascript php google-maps web google-maps-api-3

我希望获得在Google商家中添加的商家详细信息。例如,在newdelhi"中搜索"计算机商店的人。然后我想要显示在新德里的计算机商店的所有细节,在谷歌业务(或地图)列出,而不显示地图。如何在web(php或js或web中的任何编程语言)中实现。

1 个答案:

答案 0 :(得分:2)

我建议从Google Places API开始。这基本上是Maps API的一个子集。不要求实际渲染地图本身。

https://developers.google.com/places/

https://developers.google.com/maps/documentation/javascript/places#place_details

更新:

这是一个CodePen示例,显示了使用jQuery的非常快速和简单的简单示例。

var placesAPIAccessKey = '<your key here>';  

var placesSearchAPIEndpoint = 'http://crossorigin.me/https://maps.googleapis.com/maps/api/place/nearbysearch/json';
var placesLookupAPIEndpoint = 'http://crossorigin.me/https://maps.googleapis.com/maps/api/place/details/json';

var placesSearchParams = {
  key: placesAPIAccessKey,
  location: '28.5219145,77.2189402', // New Dheli, India
  radius: 5000, // 5km search radius from center point
  type: 'electronics_store',
  keywords: 'computer shop store repair service laptop notebook chromebook hp acer asus apple dell'
};

function getThePlaces() {
  $.get(placesSearchAPIEndpoint,placesSearchParams,function(data){
    $.each(data.results, function(index,content) {
      $.get(placesLookupAPIEndpoint,{
        key:placesAPIAccessKey,
        placeid:content.place_id
      }, function(data) {
        $('body').append(
          '<div>'+ 
          data.result.name + '<br>' +
          ' Address: ' + data.result.formatted_address + '<br>' +
          ' Phone: ' + data.result.formatted_phone_number +
          '</div>');
      });
    });
  });
};

getThePlaces();

指向实时CodePen的链接:http://codepen.io/pixelchemist/pen/RGjYEQ *请注意,您需要提供自己的场所API密钥才能正常工作*