【发布时间】:2015-03-22 15:42:37
【问题描述】:
我正在使用 Google Places API 并喜欢它,但似乎无法获得想要的结果。
我最终想要生成的是雷达搜索,它显示 5 公里半径内的酒吧、餐厅类型的项目。除了地图指针之外,我还想通过该地点的图标或照片拉出。
我大部分时间都在那里,但我尝试的许多照片选项都失败了。我可以将我的库中的静态图像显示为图标(在下面的代码中注释掉),但我非常喜欢这张照片。
如果这不可能,那么我想将 staticImage x 分配给 Bar 类型,将 staticimage2 分配给 y 类型。
任何人都可以解释一下我做错了什么吗?如果不可能,你能建议一种替代方法吗?
非常感谢!
for (var i = 0, result; result = results[i]; i++) {
//var place = results[i].place;
var marker = new google.maps.Marker({
map: map,
position: result.geometry.location,
place : {
placeId : results[i].place_id,
location : results[i].geometry.location,
photo : results[i].photo - doesn't work
},
title: results[i].place_id + ' : ' + results[i].geometry.location - problems here as well. :(
//icon: "/assets/images/cake_32x32.png" - This works -
//icon : results[i].photos[i].getUrl({'maxWidth': 35,'maxHeight': 35}) - This doesn't
});
【问题讨论】:
-
可能是小错误,也许你忘记了 s; results[i].photo 应该是 results[i].photos
-
@Verma - 嗨,我忘了补充一点,当在 place 对象中调用时,'photo' 是一个未知属性。我把它移到了地点对象之外,没有错误,但是,也没有照片:)
标签: javascript android google-maps google-places-api