Google places api


#1

does anyone know how to get the google places api to work, im trying to autofill and address into inputs, i tried following the post on here relating to google maps api, but got confused, can someone give me an example of this also where would i put the script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=places&callback=initAutocomplete"
async defer> /script
does this just go into the index, non reason document?


#2

this is what ive come up with so far, now im stuck

type domElement = {. "value": string};
type document = {
  .
  [@bs.meth] "getElementById" : string => domElement
};

[@bs.send] external getElementById : (document, string) => domElement = "getElementById";
[@bs.val] external doc : document = "document";
[@bs.send] external preventEventDefault : (ReactEventRe.Form.t) => unit = "preventDefault";

[@bs.deriving abstract]
type geolocation = {
  lat: string,
  lng: string,
};

[@bs.deriving abstract]
type circle = {
  center: geolocation,
  radius: string,
};

[@bs.deriving abstract]
type setup = {
  types: list(string),
};

[@bs.new] [@bs.scope ("google", "map" , "places")] external autocomplete : (domElement, setup) => unit = "Autocomplete";

[@bs.new] [@bs.scope ("google", "map" , "places")] external circle : (circle) => unit = "Circle";

[@bs.send] external preventEventDefault : (ReactEventRe.Form.t) => unit = "preventDefault";

type componentForm = {
street_number: string,
route: string,
locality: string,
administrative_area_level_1: string,
country: string,
postal_code: string
};

let types = setup(~types=["geocode"])

let initAutocomplete = () => {
 let autocomplete = autocomplete(getElementById(doc, "autocomplete"), types );

};

let fillInAddress = () => {

};

let geolocate = () => {

};

let componentForm = () => {
street_number: "short_name",
route: "long_name",
locality: "long_name",
administrative_area_level_1: "short_name",
country: "long_name",
postal_code: "short_name"
};