LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting location coordinates using GoogleMaps API

Solved!
Go to solution

Hey guys,

 

I am currently using this template LabVIEW GoogleMpas API to insert a place or coordinates into google maps and receive the result inside LabVIEW.

 

Since the API has changed I had to make a few adaptions but it works.

 

Now I want to do the following: I want to enter the name of a place and the API shall give me the coordinates --> Geocoding. The procedure is shown here:https://developers.google.com/maps/documentation/geocoding/intro?hl=de

Writing into the URL should lead to an result in "JSON":

https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&key="MyKEY"

But I dont have a clue how to receive the result of my request?!

I have added a snapshot of my attempt, but the used method is either wrong or I am not using it correctly...

 

(I have LabVIEW 2015 SP1 (32bit) + Windows 10 Education (64bit))

 

kind regards

Slev1in

 

0 Kudos
Message 1 of 3
(3,206 Views)

Hi Slevin,

 

using a browser with your URL

https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+... (I removed this silly MYKEY at the end!)

I get the following result:

{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "1600",
               "short_name" : "1600",
               "types" : [ "street_number" ]
            },
            {
               "long_name" : "Amphitheatre Parkway",
               "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" : "USA",
               "short_name" : "US",
               "types" : [ "country", "political" ]
            },
            {
               "long_name" : "94043",
               "short_name" : "94043",
               "types" : [ "postal_code" ]
            }
         ],
         "formatted_address" : "1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA",
         "geometry" : {
            "location" : {
               "lat" : 37.4223664,
               "lng" : -122.084406
            },
            "location_type" : "ROOFTOP",
            "viewport" : {
               "northeast" : {
                  "lat" : 37.4237153802915,
                  "lng" : -122.0830570197085
               },
               "southwest" : {
                  "lat" : 37.42101741970851,
                  "lng" : -122.0857549802915
               }
            }
         },
         "place_id" : "ChIJ2eUgeAK6j4ARbn5u_wAGqWA",
         "types" : [ "street_address" ]
      }
   ],
   "status" : "OK"
}

 Then all you need to do is some easy string parsing to get the values after "lat"/"lng"…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 3
(3,195 Views)
Solution
Accepted by topic author Slev1n

Hey Gerd,

 

thank you for your quick answer.

Well, I should have tried out entering that URL on my own...but thanks.

I noticed, that I always "receive" a "json" file when I execute the "Webbrowser" invoke-node. But a Windows window prompts and asks me to save the file (like every download file). Inside that file is the JSON code.

 

EDIT: I FOUND A WAY...using the following VIs (see appendix). I now just have to further process it.

 

Thanks for your help guys and merry christmas

0 Kudos
Message 3 of 3
(3,136 Views)