Ich versuche, einige Orte aus der Places Web API zu ziehen, um einige Markierungen auf einer Karte zu zeichnen. Es scheint, wie es falsch ist, einen Fehler zu werfen:Google Places-Web-API wirft Fehler falsch und bricht Karten in der Nähe abSuche
Uncaught Error: Missing parameter. You must specify location. in places_impl.js:35
Mein Code folgt:
var bounds = map.getBounds();
var service = new google.maps.places.PlacesService(map);
service.nearbySearch({
bounds: bounds,
type: ['natural_feature']
}, callback);
und es sollte gemäß der Dokumentation arbeiten
This method takes a request with the following fields:
Either of: bounds, which must be a google.maps.LatLngBounds object defining the rectangular search area; or
a location and a radius; the former takes a google.maps.LatLng object, and the latter takes a simple integer, representing the circle's radius in meters. The maximum allowed radius is 50 000 meters. Note that when rankBy is set to DISTANCE, you must specify a location but you cannot specify a radius or bounds.
https://developers.google.com/maps/documentation/javascript/places#place_search_requests
für bounds_changed Ereignis Feuer Warten hat seinen Zweck erfüllt. jedoch In der Dokumentation: _If die Karte noch nicht initialisiert (dh die mapType ist noch null) oder in der Mitte und Zoom nicht eingestellt worden ist, dann ist das Ergebnis null oder undefined._ In meinem Fall wurde ich Initialisierung Die Karte und Zentrum und Zoom wurden eingestellt. Also immer noch seltsam. Wie auch immer, Prost. – SovMoose
Die Map wird asynchron initialisiert, die Grenzen sind nicht verfügbar, bis das Ereignis "bounds_changed" zum ersten Mal ausgelöst wird. – geocodezip
Ich sehe. Danke für die Hilfe – SovMoose