【发布时间】:2016-10-04 09:36:49
【问题描述】:
我想获取在谷歌业务中添加的业务详细信息。例如,搜索“新德里的电脑商店”的人。然后我想显示新德里电脑商店的所有详细信息,这些信息在谷歌业务(或地图)中列出,而不显示地图。在 web 中如何实现(php 或 js 或 web 中的任何编程语言)。
【问题讨论】:
标签: javascript php google-maps web google-maps-api-3
我想获取在谷歌业务中添加的业务详细信息。例如,搜索“新德里的电脑商店”的人。然后我想显示新德里电脑商店的所有详细信息,这些信息在谷歌业务(或地图)中列出,而不显示地图。在 web 中如何实现(php 或 js 或 web 中的任何编程语言)。
【问题讨论】:
标签: javascript php google-maps web google-maps-api-3
我建议从 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 密钥才能使用 *
【讨论】: