Example Code

Google Maps in LabVIEW

Code and Documents

Attachment

Download All

Overview

This VI allows you to use Google Static Map to search for a specific location (defined by latitude and Longitude), pin it and draw the path with another point.

 

 

Description

The code was made using state machine design pattern to enable you to place more than 1 point on the map, draw the path between 2 selected points and update the map properties i.e. size, zoom and format. Each time you use the Google Maps APIs you must include a key, or other credentials, to validate your request. To get a Google Maps API key, go here

You can use this VI to set a specific location or in GPS tracking applications.

 

 

Steps to Implement or Execute Code

1. Download the project and open Google Static MAPs API_LV2012.vi

2. Open the block Diagram and Navigate to Update Map state

3. Enter your Google Maps API key after you create it from the above link

4. Run the VI

5. Choose the Latitude and Longitude

6. Clock on Add Marker. You can add another one if asked or click on cancel

7. If you modify the parameters click on Refresh

8. Choose the 2 points from Path Properties then click on show path to display the path between them.

9. Stop Execution

 

 

Requirements:

LabVIEW 2012 (or compatible)

 

 

Additional Information or References

Front Panel

FP.PNG

 

Block Diagram

 BD.PNG

 

 

 

 

**This document has been updated to meet the current required format for the NI Code Exchange.** 

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
Active Participant
Active Participant
on

Nice job using the Google API.  The next natural step it seems might be to do this using Google Maps in offline mode.  This would be useful for applications where you have a data feed for position but don't have a connection to the internet.  Any thoughts?

Member
Member
on

Dear,  I like your concept (not runned the program yet).  I have list of 3000 sites + [latitude and longitude in ms excel] for which i need to bookmark/ balloon and find distances / time for each site. Doing this manually is very hectic.  Please guide me to make a loop which would take data from :  1) Excel file. 2) Bookmark in googlemap [with site name]. 3) find distance for n number of site/s. 4) find hour between each site/s. 5) output in excel form and google map page.            site1        site 2 ...... site1  0 km         15 km site 2  300 km   200 km . . . Secondly to download API they are asking URL (which i dont have), so would your tweaks work.  Thanks Usman

Member
Member
on

Dear macaba

I think youre API application very interesting, with a lot of applications. I downloaded ur zip file and when  I try to download the Google API they ask for my URL. We need a http server  to use your LabView application ?

Thanks in advance

Trusted Enthusiast
Trusted Enthusiast
on

Thanks a lot for the job! That's very useful!

I also agree with mtat76 - offline mode would be super

Member
Member
on

Man very nice and many thanks

May god bless you

thank you

one thing tough, I was able to use it without getting a key!

how is that posible.

anyways, when i went to get a key, i was asked to choose one of these options, which one do you think is relivant to labview?

1- Google Maps JavaScript API v3

2- Google Earth API

3- Google Maps JavaScript API v2

4- Google Maps API for Flash

Member
Member
on

excellent job, this works without the key!

Member
Member
on

Hi

I am using this code to access the Google Maps and it works; but can not put a balloon for the new coordinates that i'm entering for Longitude and Latitude. How can I solve this problem?

Thank you!

Proven Zealot
Proven Zealot
on

Hi Andrei02 and Macaba,

How can it work? Can you please give me some advise.

I have tried this code but it is not work without API key.

I am trying to create some Google API key, but I got only 40 Character (not 86 character key no matter which API type)

and this API key does not work with code.

Moreover, when I copy url and paste to google chorme, it showed that this ulr need different API key.

Thank you in advace

Chomphunut N.

Applications Engineer | National Instruments
Singapore (65) 6226 5886 | Malaysia (60) 3 7948 2000 | Thailand (66) 2 298 4800
Philippines (63) 2 659 1722 | Vietnam (84) 28 3911 3150 | Indonesia (62) 21 2783 2355
Trusted Enthusiast
Trusted Enthusiast
on

Other example of using Google API
https://decibel.ni.com/content/docs/DOC-12505

Hope will be  useful!

Member
Member
on

Hi Team

How can I using labVIEW with Google offline maps api?

Thanks

Luong.Tran

Member
Member
on

Hi!

Have you this program for LabVIEW 2012???

Thanks

Igor

Trusted Enthusiast
Trusted Enthusiast
on

Technically, it is opened in LV2012 without any issues.

Member
Member
on

How can i get 86 key google maps api? thx

Member
Member
on

Thanks, this was a great starting point. The URL doesn't require a key anymore but the starting point of the URL has changed: Use maps.googleapis.com instead.

For example

http://maps.googleapis.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=13&size=600x30...|label:S|40.702147,-74.015794&markers=color:green|label:G|40.711614,-74.012318&markers=color:red|label:C|40.718217,-73.998284

You may also google for "static map api" and find a lot of additional information. There some alternatives to be found at https://justmarkup.com/log/2014/05/27/overview-of-static-map-solutions/


Member
Member
on

hi, i'm using your code thank you

and i have a question. java program is used in this process? please answer my question

Member
Member
on

Because only an image of google maps handled as podriar make out more images please answer my question

Member
Member
on

I could explain how his ballon work because I do not mark the spot?

Member
Member
on

Muy buen aporte me sirvio de mucho, para los que tengan problemas con la API este programa funciona sin API pues google a modificado, solo debe arreglar como se esta generando el link que deberia ser de esta manera   http://maps.googleapis.com/maps/api/staticmap?center=-3,986791,-79,199378&zoom=16&size=572x350&mapty...

Al igual los que tienen problemas con generar el puntero dentro del mapa unicamente deben arreglar el link,

crisbae26@hotmail.com

Member
Member
on

Hello.
I tried using the key you mentioned, but it does not work.

http://maps.googleapis.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY &zoom=13&size=600x3...|label:S|40.702147,-74.015794&markers=color:green|label:G|40.711614,-74.012318&m


Can you please help me with this?  How do I get a key for myself?

Thank you

Member
Member
on

Hello ishraque,

This URL doesn't have a key. The API also works without a key but will has a low limit on the numbers of maps you can retreive on one day. I checked the link in your post on another machine and it works fine.

You only copied a part, the section after the 'm' should become 'markers....' from the previous line but works fine as you copied it as well. Even when you only click the hyperlinked in your post. What do you get?

Kind regards,

Mark

Member
Member
on

I am always getting this error. Capture.PNG

Member
Member
on

OK,

I didn't use the vi, just copy the URL in your browser. The vi creates it's own URL which has the key field. If the key field is present it must be used. You can use the URL that I supplied to debug the call string generated by the vi.

If you don't want to use a key (for quick starting, to see how everything works) remove the last two inputs of the upper build string (the constant '&key=' and the API key control.

How to get a key for the google API changes every now and then... Best is to 'google' it. Seems they changed it again starting this year: https://developers.google.com/maps/faq?hl=en#keysystem . This method use the webapi so you need a browserkey.

Member
Member
on

hello,

i got a smilar error as ishraque1 API.PNG , however i created a browser API but it wasnt of length 86 alphnumeri, instead it was 39. To be honest i have no idea where to enter the API key

please help

Member
Member
on

if i wanna use this code with arduino and gps module , how can i do it (what should i learn )

Member
Member
on

I have tried this VI.For the marker and center worked fine. But when i tried to make a path, it did not show any path (Geocoding error:path 1)

Later i found out that when we use path parameter, we should not include other parameter like marker, center and zoom. So rather than adding parameter, i modify the VI so it choose only 1 parameter.

 

Am i the only 1 who encounter this?

 

If you are using arduino, you can control it through LIFA or LINX (Download it from VIPM) or control it through VISA("You should also program the arduino to communicate serially to PC). I see some labVIEW compiler for arduino, maybe you can try it and share it with us.

 

For GPS module, you should learn about the protocol your module use. Usually it uses NMEA protocol. For this protocol, to put it simple, you only need to configure UART to write(Send command(Proprietary sentence) to the module and to read (Receive NMEA response). To obatain your location , speed and etc, just parse the NMEA response.

 

Does it help?

Kudos and Marked as Solution == Thanks
Member
Member
on

Hello is there someone who can s197753_API.PNGend me the version of the program shown in the picture.

Member
Member
on

Can me full tutorial step by step for trajectori GPS with maps in labview?