Google 地图API 获取位置地址以及域信息
Google Maps API to get location address as well as domain information
我正在使用 Google 地图 Javascript API 并使用地点库。虽然我能够获取位置地址,但我还需要获取位置域信息,例如假设该位置是一家企业并且还有一个网站 URL 链接到该位置。谁能引导我到右边 API 或也提供位置域信息的图书馆?到目前为止我还没有遇到过。
使用 places
库获取其他信息
//make a request variable attaching the data you require , make sure to use only those which you require as detail request are billed separately
var request = {
query: 'yourquery',
fields: ['address_component', 'website']
};
service = new google.maps.places.PlacesService(map);
service.getDetails(request, callback);
//Here you get the result
function callback(place, status) {
if (status == google.maps.places.PlacesServiceStatus.OK) {
var website = place.website; // get the website, may be empty
var type = place.address_component.types[0]; //this is an array and can be empty
}
}
我正在使用 Google 地图 Javascript API 并使用地点库。虽然我能够获取位置地址,但我还需要获取位置域信息,例如假设该位置是一家企业并且还有一个网站 URL 链接到该位置。谁能引导我到右边 API 或也提供位置域信息的图书馆?到目前为止我还没有遇到过。
使用 places
库获取其他信息
//make a request variable attaching the data you require , make sure to use only those which you require as detail request are billed separately
var request = {
query: 'yourquery',
fields: ['address_component', 'website']
};
service = new google.maps.places.PlacesService(map);
service.getDetails(request, callback);
//Here you get the result
function callback(place, status) {
if (status == google.maps.places.PlacesServiceStatus.OK) {
var website = place.website; // get the website, may be empty
var type = place.address_component.types[0]; //this is an array and can be empty
}
}