Share My Creation GPS Example

Do not use this program it is a very old one which was released before the GoogleMaps library was released.
Many things have changed since the release of this program and it does no more work as expected.
I have not updated it to satisfy the new requirements of Google which have become more and more restrictive.

Here is a GPS Example program with following functions:
  • Connect the GPS
  • Get and display GPS information
  • Save a GPS path (program internal GPP format and Google Earth KML format)
  • Display the available satellites
  • Display Google maps
  • Display a GPS path on the map
  • Shows current GPS position on the map
Google map functions, user settable :
  • Display zoom control
  • Display scale control
  • Display a path
  • Display markers
  • Move a marker
  • Display coordinates (touch the screen)
  • Move the map / Display coordinates (touch the screen and move)
Some special features:
  • Table with first column always visible. Image GPS_3.
  • Touching a button changes it's color and shows a tooltip on top of the screen. Releasing it insides the button area executes the function and hides the tooltip. Releasing outsides the butoon area does not execute the function and hides the tooltip. This allows to check a button function without executing it. Image GPS_4
  • Touching some buttons displays 'subbuttons' to select other setup parameters more easily rather than doing it in the setup screen. Image GPS_5
Comments on the images:
  • GPS_1 Display of a GPS path with polyline and markers
  • GPS_2 Display of current GPS data with the position on the map
  • GPS_3 Display of GPS path data in a table
  • GPS_4 Main screen, display of a tooltip, just touched the PATH button before releasing it
  • GPS_5 Display of 'subbuttons' to select setup parameters
  • GPS_6 Display og Satellites data
  • GPS_7 Setup screen
  • GPS_8 Save screen with one button foe each file format
  • GPS_9 Shows InfoWindow
It is designed for smartphones and does work only in portrait mode.

The program needs following additional libraries:
- ByteConverter
- Dialogs
- RandomAccessFile
- WebViewExtras
- ScrollView2D

Thank's to warwound for the WebViewExtras library, that allowed adding events to the GoogleMaps WebView.

The programs functionalities are explained in the Basic4Android User's Guide and some code is also explained.
If there are some code parts you would like having explained in the Basic4Android User's Guide post the request in this thread.

Best regards.

EDIT: 2011.12.20 version 1.1
Updated the source code after the bug reports.

EDIT: 2011.12.21 version 1.2
Added the maptype_changed event, problem reported by dlfallen in post#21

EDIT: 2011.12.22 version 1.3
Changed the zoom calculation
Added MapTypeControlID choice
Added MapZoomControlStyle choice

EDIT: 2011.12.23 version 1.4
Amended the problems reported by dlfallen

EDIT: 2011.12.27 version 1.5
Added saving of a GPS path in Google Earth KML format.
Removed the short help file, the help is in the Beginner's Guide.

EDIT: 2011.12.28 version 1.51
Amended bug reported by timo in post #37

EDIT: 2012.02.06 version 1.55
Amended bug report by msains in post #56

EDIT: 2012.02.06 version 1.56
Amended bug report by alfcen in post #59

EDIT: 2012.02.08 version 1.60
Amended bug report by Andras in post #64

EDIT: 2012.06.02 version 1.70
Added most of Barry Sumpters' wishes
Amended input from Filippo (German forum)
Added an InfoWindow for the first marker, when clicking on the first Marker an InfoWindoe is displayed.

EDIT: 2012.06.12 version 1.80

Added a filter to remove close locations.
Improved some function and removed some bugs.

EDIT: 2012.10.09 version 2.00
Updated for tablets.
Works only in portrait on phones and both orientations on tablets.
Needs Basic4Android version 2.2 (uses AutoScale)

EDIT: 2013.03.06 version 2.1
Amended error reported in post #142.

EDIT: 2014.08.09 version 2.2
Added altitude above sea level post #175

EDIT: 2015.04.17 version 2.3
Amended error reported in post #179
Amended some minor bugs

EDIT 2018.02.15 version 2.6
Removed DoEvents
Replaced File.DirRootExternal by GetSafeDirDefaultExternal.
 

Attachments

  • GPS_1.jpg
    GPS_1.jpg
    62.1 KB · Views: 49,221
  • GPS_2.jpg
    GPS_2.jpg
    61.6 KB · Views: 4,412
  • GPS_3.jpg
    GPS_3.jpg
    74.8 KB · Views: 48,659
  • GPS_4.jpg
    GPS_4.jpg
    46.7 KB · Views: 3,867
  • GPS_5.jpg
    GPS_5.jpg
    66.1 KB · Views: 3,939
  • GPS_6.jpg
    GPS_6.jpg
    33.9 KB · Views: 3,742
  • GPS_7.jpg
    GPS_7.jpg
    42.3 KB · Views: 3,973
  • GPS_8.jpg
    GPS_8.jpg
    33.1 KB · Views: 3,581
  • GPS_9.jpg
    GPS_9.jpg
    52.8 KB · Views: 3,862
  • GPSExampleV2_6.zip
    134.5 KB · Views: 2,087
Last edited:

legion48

Member
Licensed User
Longtime User
Thanks for that WarWound. Now I'm Getting this:

Compiling code. Error
Error parsing program.
Error description: Unknown type: byteconverter
Are you missing a library reference?
Occurred on line: 108
Dim bc As ByteConverter


Any idea what library this needs?
 

legion48

Member
Licensed User
Longtime User
Thank you Klaus, I have it working now.

What a wonderful example to provide us with, thanks very much.:)
 

priusfan

Member
Licensed User
Longtime User
thank you Klaus for this complete lesson.

I have a small question regarding the "autoscaling" of the "selector" top right on the map wiew.

I changed your project to accept both orientations and I tested on a phone (HTC HD 800 x 480 scale= 1.5) and a tablet (Asus Transformer TF101 1280 x 752 scale = 1 ).

My question:
I selected hybrid view, so I can switch between map and satellite.
on the phone and not on the tablet, when I zoom-in, the selector changes size, and I would like to understand the mecanism behind.
here are 2 pictures to illustrate:
14f03238529954.png

14f0323854149c.png
 

klaus

Expert
Licensed User
Longtime User
There is an option parameter for the MapTypeControl I have not set.
The MapTypeControlStyle, this one is DEFAULT as it has not been changed.
The default style can change according to the screen size.
GoogleMaps documentation.
I change only the MapTypeControlID property. The size and style are automaticaly changed.
You could try to add the MapTypeControlStyle property to see what happens.

Best regards.
 

sheriffporter

Member
Licensed User
Longtime User
Meters per second to MPH

Anybody have a simple routine to convert the GPS speed output from Meters per second to MPH? Or is there a way to format the output with the library?
 

mkvidyashankar

Active Member
Licensed User
Longtime User
Anybody have a simple routine to convert the GPS speed output from Meters per second to MPH? Or is there a way to format the output with the library?

Conversion is simple multiply the output of gps speed by 2.2369362920544, that will give speed in miles per hour
 
Last edited:

sheriffporter

Member
Licensed User
Longtime User
Got that. Any idea how I can format the return so I don't get like 8 numbers past the decimal point? It keeps jumping around...

Here is what I have now: ( tried 0,0,0 and a few other variations, no luck)

lblSpeed.Text = (NumberFormat2(Location1.Speed,1,1,2,False) *2.23)

I would like to have just one digit with no fractions for the output in MPH.
 

klaus

Expert
Licensed User
Longtime User
Anybody have a simple routine to convert the GPS speed output from Meters per second to MPH? Or is there a way to format the output with the library?
Just for your information, the speed conversion does already exist in the GPSExample program. When you touch the header of the speed column the speed unit does change from m/s to km/h to miles/h and so on.
It's done in the UpdateDispSpeed routine in the GPSPaths module.

Best regards.
 

kahonen

New Member
Licensed User
Longtime User
I'm trying to compile the GPS demo and I'm getting the following error:

Compiling code. Error
Error parsing program.
Error description: Unknown type: webviewextras
Are you missing a library reference?
Occurred on line: 138
Dim MapViewerExtra As WebViewExtras


I've seen the other posts about the additional libraries I need and have created an AddLibraries folder and have ByteConverter, Dialogs, WebViewExtras in there.

Anyone offer any further suggestions?

Edited to add: I just checked and I can compile and run the WebViewExtras demo program.
 
Last edited:

kahonen

New Member
Licensed User
Longtime User
Problem fixed. My apologies.

I hadn't used the check boxes to add the libraries.

Amazing the difference reading the manual makes :BangHead:
 

JoanRPM

Active Member
Licensed User
Longtime User
It's a very good example.
I'll have to look in depth. I'm a beginner and I'm still learning how everything works.
Thanks.
 

msains

Member
Licensed User
Longtime User
Number Format Exception

Morning all
When Running the GPS Example on my Galaxy Tab 10.1 or on my HD2 phone I get the following exception:

Error Occurred
An Error has occurred in sub: main_gps1_locationchanged (java line: 1415)
lava.lang.
NumberFormatException
Continue ?

--
The App sterts Ok and picks up several sattelites in the SATS Tab, but will go no further.

btw: I notice that the Altitude reading is '1,653.1' and it seems that the format of this should not have the ',' (comma) in it. Perhaps this is what is troubling the java NumberFormatException.

Is there perhaps a setting in my phone I can change (ie to make the format of the Altitude returned from my GPS 'correct') or is it an omission in the java library that stops it from properly handling an Altitude (or any other number) that is returned with a ',' in the string ?

I'd appreciate some advice on getting this App to work in the same way everyone else seems to have done.
 

msains

Member
Licensed User
Longtime User
Works well

Thanks Klaus
It works nicely on both devices now.

I'm really looking forward to learning from your code

I hope I can contribute something every now and again as a gesture of respect and thanks for your very generous code and postings.

Thanks again

Malcolm ;)
 

alfcen

Well-Known Member
Licensed User
Longtime User
Splitting hairs

Gruetzi Klaus,

Sorry for splitting hairs once again (I think in French you'd say, "splitting hairs into 4 pieces"). Anyway, there are a couple of undefined variables...

Activity Main
MapYCursor: Line 32 (declares MapXCursor twice)

Activity GPSPaths
GPSFilenameOld: line 106
txt: lines 228/252
MapZoomCalculated: line 260
GPSPathModified: lines 280/785

Activity Satellites
txt5: Line 36
 

klaus

Expert
Licensed User
Longtime User
Hallo Robert,
Thank's for having "coupé les cheveux en 4", but I don't consider it like that.
I had'n looked at the code with the IDE version1.8, the new feature showing non declared variables is very useful.
In the first post I updated the program version 1.56

Best regards and thank you.
 
Top