Angular2:如何获得google place';从地点id的照片?
我想从angular2应用程序中的PlaceID检索google place照片。我从自动完成方法中获取placeId 我正在使用angular2谷歌地图库 } 通过使用place_id或Lattude和longitude,我想获取该地点的前10张照片。我被angular2谷歌地图困住了 你们能帮帮我吗。Angular2:如何获得google place';从地点id的照片?,angular,typescript,angular2-google-maps,Angular,Typescript,Angular2 Google Maps,我想从angular2应用程序中的PlaceID检索google place照片。我从自动完成方法中获取placeId 我正在使用angular2谷歌地图库 } 通过使用place_id或Lattude和longitude,我想获取该地点的前10张照片。我被angular2谷歌地图困住了 你们能帮帮我吗。 谢谢。有了这个placeId,你就可以使用这个类了。调用getDetails方法,在回调中收到一个PlaceResult,它有一个photos属性(它是一个数组,您可以调用getUrl方法来检
谢谢。有了这个placeId,你就可以使用这个类了。调用
getDetails
方法,在回调中收到一个PlaceResult
,它有一个photos
属性(它是一个数组,您可以调用getUrl
方法来检索可显示的图片)
(这意味着您已经检索了Place库以及核心google maps API库)
[编辑]
实际上,由于使用了Autocomplete
,因此您已经有了PlaceResult
,这就简单多了
function RetrievePhotoUrlsFromPlace(place) {
var photos = place.photos;
var urls = []; // we will store the urls here
photos.forEach((photo) => {
urls.push(photo.getUrl({
maxWidht: 500, // at least set one or the other - mandatory
maxHeight: undefined
}));
});
/* You have your URLs here !! */
}
有了这个placeId,您就可以使用这个类了。调用
getDetails
方法,在回调中收到一个PlaceResult
,它有一个photos
属性(它是一个数组,您可以调用getUrl
方法来检索可显示的图片)
(这意味着您已经检索了Place库以及核心google maps API库)
[编辑]
实际上,由于使用了Autocomplete
,因此您已经有了PlaceResult
,这就简单多了
function RetrievePhotoUrlsFromPlace(place) {
var photos = place.photos;
var urls = []; // we will store the urls here
photos.forEach((photo) => {
urls.push(photo.getUrl({
maxWidht: 500, // at least set one or the other - mandatory
maxHeight: undefined
}));
});
/* You have your URLs here !! */
}
我按照您的解决方案进行了尝试,但出现了以下错误:google.maps.places服务不是一个构造函数您可能没有加载Place库是的,我添加了
AgmCoreModule.forRoot({apiKey:GOOGLEAPIKEY,libraries:[“places”]})
my bad它是新的google.maps.places.places服务
,我更新我的帖子我们需要将htmldevelment或Map
作为参数传递到PlacesService()代码>方法?根据您的解决方案,它给出了一个错误,无法读取未定义的属性'innerHTML',但得到这个错误google.maps.places服务不是一个构造函数您可能没有加载位置库是的,我添加了AgmCoreModule.forRoot({apiKey:GOOGLEAPIKEY,libraries:[“places”]})
my bad它是新的google.maps.places.PlacesService
,我更新了我的帖子我们需要将HtmlLevel或Map
作为参数传递到PlacesService()代码>方法?它给出了一个错误,无法读取未定义的属性“innerHTML”
function RetrievePhotoUrlsFromPlace(place) {
var photos = place.photos;
var urls = []; // we will store the urls here
photos.forEach((photo) => {
urls.push(photo.getUrl({
maxWidht: 500, // at least set one or the other - mandatory
maxHeight: undefined
}));
});
/* You have your URLs here !! */
}