Source: site.view [edit]
Function name: googlePlace
Arguments: addressOrPlace
Description:
Page type: webl
Render function:  
Module: global

Page source:

var getVal = fun(P, field) 
   var val = nil;
   every comp in Elem(P, "types") do
      if Str_Trim(Text(comp)) == field then
         var E = Elem(P, "short_name") inside Parent(comp);
         if Size(E) > 0 then
            val = Str_Trim(Text(E[0]));
         end
      end
   end;
   return val
end;
  
var getVal2 = fun(P, field)
   var val = nil;
   var E = Elem(P, field);
   if Size(E) > 0 then
      val = Str_Trim(Text(E[0]))
   end;
   return val
end;


var res = [. .];

var P = GetURL("https://maps.googleapis.com/maps/api/place/textsearch/json?query=" + Url_Encode(Str_Trim(addressOrPlace)) + "&key=AIzaSyAO2RntyX5IUgDJmXO-i39U06wwIhKwdEE", [. .]);


res["name"] := getVal2(P, "name");
res["lat"] := getVal2(P, "lat");
res["lng"] := getVal2(P, "lng");
res["formatted_address"] := getVal2(P, "formatted_address");
res["icon"] := getVal2(P, "icon");
res["type"] := getVal2(P, "types");
res["placeid"] := getVal2(P, "place_id");

res;