尝试从 Google Places API 中提取数据,但在阅读文档后无法正常工作。我一定错过了什么,有人可以帮忙吗?
<script>
var request = {
location: new google.maps.LatLng(-33.8665433,151.1956316),
radius: '500',
types: ['store']
};
var service = new google.maps.places.PlaceService(map);
service.nearbySearch(request, callback);
function callback(results, status) {
for(var i = 0; i < results.length; i++){
document.write(results[i] + '<br/>');
}
};
</script>
通过将代码更改为此,我得到了错误:
var request = {
location: new google.maps.LatLng(-33.8665433,151.1956316),
radius: '500',
types: ['store']
};
service = new google.maps.places.PlacesService(map);
service.nearbySearch(request, callback);
if (status == google.maps.places.PlacesServiceStatus.OK){
function callback(results, status) {
for(var i = 0; i < 7; i++){
document.write(results[i] + 'test <br/>');
}
}
};
</script>
但是它仍然没有返回任何数据。请有人帮忙。谢谢!!!