So I'm trying to get details based on a google places text search. My text search is working fine, but to get details I keep getting "Invalid Request".
I've followed examples from the documentation, as well as examples from other people but to no avail, I have failed....
This is my text search, which is working.
var lat = '43.09182244507046'
var lng = '-89.48985488807972'
var places;
function initialize() {
var location = new google.maps.LatLng(lat,lng);
var map = new google.maps.Map(document.getElementById('map'),{
center: location,
zoom: 15
});
var request = {
location: location,
radius: '50000',
query: 'food'
};
var callback = function (results, status) {
places = results;
console.log(status);
console.log(places);
}
var service = new google.maps.places.PlacesService(map);
service.textSearch(request, callback);
}
This is my place details search which is getting an Invalid Request status
var place_details;
function getDetails() {
var location = new google.maps.LatLng(lat,lng);
var map = new google.maps.Map(document.getElementById('map'),{
center: location,
zoom: 15
});
var callback = function (results, status) {
place_details = results;
};
var service = new google.maps.places.PlacesService(map);
service.getDetails({
placeId: "8deae188679ff8b9344085de5360a769879240f9"}, function(place, status){
place_details = place;
console.log(place_details);
console.log(status);
}
);
}
I had the if(status === google.maps.places.PlaceService.OK) in there. So that's not the issue in case anyone catches that.
Any help would be appreciated... I want this to work!
8deae188679ff8b9344085de5360a769879240f9
is not a Place ID. I suspect you're using PlaceResult.id
which doesn't work with details requests and is deprecated.
Instead use PlaceResult.place_id
. See the documentation for details and examples.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With