Google Place API in Javascript

I want to use Google Place API for Autocomplete text and Place Detail. Please help me if there is some way to do so using Javascript or any other method (I don’t want to use Google API Web Services for the same as it has some limitations). If something like that is not possible now please let me know whether it is in your future preferences or not, as my project is on hold due to this problem.

It is not possible to use the JavaScript API that Google supplies as this is for the DOM. You should be able to implement the API in JavaScript or Uno, but not use any of the existing SDKs.

I’ve had a look at this, and to do this in pure JS is pretty straight forward.

Thank You for your reply. Can you guide me, how to do the same. Please provide a sample/example for the same.

Is it possible to use https://github.com/Srirangan/googleplaces.js/tree/master in Fuse. Please can you give some clue, how can I implement the same in Fuse.

Hi!

Here is some js that might help you.

var url = "https://maps.googleapis.com/maps/api/place/autocomplete/json";
var type = "address";
var language = "sv";
var key = "GOOGLE API KEY";
var input = "" //Address input
var params = "url="+url+"&type="+type+"&language="+language+"&key="+key+"&input="+input;

var http = new XMLHttpRequest();
http.open("GET", url+"?"+params, true);
http.onreadystatechange = function() {
    if(http.readyState == 4 && http.status == 200) {
        debug_log(http.responseText);
        var myArr = JSON.parse(http.responseText);
    }
}
http.send(params);

Thanks jonas for reply, but the code is using web service, but it has some limitations. I want JavaScript for using the API.

Hmm… not sure what you are meaning. The code above is just javascript, and it’s calling the Google Places API.

The code above is using HttpRequest (Google Place API Web Service) which has usage limit of 10000 requests for 24 hours(10 request for 1 place search) , which would exceed our reqiurement, whereas Google Places API for Javascript Library has unlimited usage.

For Further reference you can refer https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete,https://developers.google.com/maps/documentation/javascript/places-autocomplete and https://developers.google.com/places/web-service/usage

Okej, I understand. Only have experince using the Web Service, so can’t help you.

Thank you for your response.

anupriyashakaya: The googleplaces.js npm package, and the google browser javascript are using the same endpoint, and has the same limitations.

Thanks for the information. I was also going through the same and came to know that npm google-places is using Web Services only. Google Places JavaScript Library do not have any limitations (as mentioned in https://developers.google.com/maps/documentation/javascript/places). I came through another work https://github.com/Carrooi/Js-GoogleMapsLoader is this would be helpful.