【问题标题】:How to get the business details using google business如何使用谷歌业务获取业务详细信息
【发布时间】:2016-10-04 09:36:49
【问题描述】:

我想获取在谷歌业务中添加的业务详细信息。例如,搜索“新德里的电脑商店”的人。然后我想显示新德里电脑商店的所有详细信息,这些信息在谷歌业务(或地图)中列出,而不显示地图。在 web 中如何实现(php 或 js 或 web 中的任何编程语言)。

【问题讨论】:

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


    【解决方案1】:

    我建议从 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 * 请注意,您需要提供自己的 Places API 密钥才能使用 *

    【讨论】:

    • 如何获取德里的电脑店列表。
    • 用一个简单的例子更新了我的回复,请注意你需要提供你自己的 API,你可以从 google 和端点 uris 上的 crossorigin.me 前缀,这是 codepen 需要的,可以是如果在其他地方运行则排除
    • 我得到了结果。谢谢@nathaniel
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-19
    • 1970-01-01
    • 2013-10-29
    • 1970-01-01
    • 1970-01-01
    • 2019-11-17
    相关资源
    最近更新 更多