JDi*_*522 3 javascript google-maps google-places-api
我在我的JavaScript应用程序中使用Places库。当我使用该service.nearbySearch()方法查找附近的地方时,效果很好。然后,当我提出service.getDetails()请求时,我会获得OVER_QUERY_LIMIT每个请求的状态。在我的开发者控制台中,我可以跟踪对Google Maps JavaScript API v3的每个请求,但是我没有从places API获得任何结果。
以下是一些代码:
// How I load the library
<script src="https://maps.googleapis.com/maps/api/js?libraries=places&key=API_KEY"></script>
// My places request
var places = new google.maps.places.PlacesService(map);
var location = new google.maps.LatLng(lat, lng);
var request = {
location: location,
radius: radius,
types: [type]
};
places.nearbySearch(request, function(results, status, pagination) {
if (status === google.maps.places.PlacesServiceStatus.OK) {
for (var i = 0; i < results.length; i++) {
// Get the details for each place
var detailsRequest = { placeId: results[i].id }
places.getDetails(detailsRequest, function(place, status) {
if (status == google.maps.places.PlacesServiceStatus.OK) {
console.log('PLACE', place)
} else {
console.log('STATUS', status)
}
})
};
}
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
| 归档时间: |
|
| 查看次数: |
3168 次 |
| 最近记录: |