我有以下代码:
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
pos = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
var request = {
location: pos,
radius: 500,
types: ['store']
};
infowindow = new google.maps.InfoWindow();
var service = new google.maps.places.PlacesService(map);
function createMarker(place) {
var placeLoc = place.geometry.location;
var marker = new google.maps.Marker({
map: map,
position: place.geometry.location
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent(place.name);
infowindow.open(map, this);
});
}
function callback(results, status) {
if (status == google.maps.places.PlacesServiceStatus.OK) {
for (var i = 0; i < results.length; i++) {
createMarker(results[i]);
}
}
}
service.nearbySearch(request, callback);
});
}
附近搜索返回:“INVALID_REQUEST”、“NOT_FOUND”、“OK”、“OVER_QUERY_LIMIT”、“REQUEST_DENIED”、“UNKNOWN_ERROR”、“ZERO_RESULTS”但是当我使用这里给出的坐标时https://developers.google.com/maps/documentation/ javascript/places而不是 currentposition 它可以正常工作。当我尝试其他坐标时,它会返回上述错误,有什么问题?