Google APIs MAPs Geocoding

How to extract just one field and values from that field, for example: {"location":, {"lat": "value"} and {"lng": "value"}} from a return from the Google Maps API.

I have already tried the LOCKUP, MAP and FIND functions to extract an API return but without success.

{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "1600",
               "short_name" : "1600",
               "types" : [ "street_number" ]
            },
            {
               "long_name" : "Amphitheatre Pkwy",
               "short_name" : "Amphitheatre Pkwy",
               "types" : [ "route" ]
            },
            {
               "long_name" : "Mountain View",
               "short_name" : "Mountain View",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Santa Clara County",
               "short_name" : "Santa Clara County",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "California",
               "short_name" : "CA",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "United States",
               "short_name" : "US",
               "types" : [ "country", "political" ]
            },
            {
               "long_name" : "94043",
               "short_name" : "94043",
               "types" : [ "postal_code" ]
            }
         ],
         "formatted_address" : "1600 Amphitheatre Parkway, Mountain View, CA 94043, USA",
         "geometry" : {
            "location" : {
               "lat" : 37.4224764,
               "lng" : -122.0842499
            },
            "location_type" : "ROOFTOP",
            "viewport" : {
               "northeast" : {
                  "lat" : 37.4238253802915,
                  "lng" : -122.0829009197085
               },
               "southwest" : {
                  "lat" : 37.4211274197085,
                  "lng" : -122.0855988802915
               }
            }
         },
         "place_id" : "ChIJ2eUgeAK6j4ARbn5u_wAGqWA",
         "plus_code": {
            "compound_code": "CWC8+W5 Mountain View, California, United States",
            "global_code": "849VCWC8+W5"
         },
         "types" : [ "street_address" ]
      }
   ],
   "status" : "OK"
 }

Have you defined this as a Data resource or are you using HTTP Request.

If it’s a Data resource, you should have results as Response key path defined in Data configurator for the Get Collection method. Then you can run a test for the Data resource and Set schema from that response. It’ll make easier for you to access the data you want.

But either way, if you have the data you pasted here available, you have tried using the correct Formulas. If you have the schema set in Composer you can just use MAP.

MAP(pageVars.googleMaps.results, {location: item.geometry.location})

This should help you get closer to what you’re looking for. It returns a List of Objects that includes location coordinates for all results in the original List. (Now I just used Page variable as an example, but that can be replaced with data. or outputs["HTTP Request"] however you like.

On the other hand, if you want the location of a certain record in the results List, you can use this type of Formula:

LOOKUP(LOOKUP(PICK_ITEM(pageVars.googleMaps.results, 0), "geometry"), "location")

Instead of 0 you can add the index of the record you want.

I hope that you can utilize and modify these to fit whatever is your exact use case.

I used a data resource, using the fantastic Rest API direct integration resource.
And I also have a variable that takes this resource.

I am now testing the friend’s excellent tips …

Thank you very much !!

@Tomi_Laakson

It worked perfectly, thank you very much !!!

God be with you !!!

1 Like

Fiz uns ajuste para as necessidades do meu caso, e funcionou perfeitamente.
Graças ao amigo @Tomi_Laakso !!!

Parabéns, e mais uma vez muito obrigado !!!

In the formula editor !!!


Source by: @Carlos_Roberto

Testing the Web App


Source by: @Carlos_Roberto

What does your config look like for a call like this?