Share My Creation GPS Example

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: 48,554
  • GPS_2.jpg
    GPS_2.jpg
    61.6 KB · Views: 4,351
  • GPS_3.jpg
    GPS_3.jpg
    74.8 KB · Views: 48,597
  • GPS_4.jpg
    GPS_4.jpg
    46.7 KB · Views: 3,815
  • GPS_5.jpg
    GPS_5.jpg
    66.1 KB · Views: 3,886
  • GPS_6.jpg
    GPS_6.jpg
    33.9 KB · Views: 3,687
  • GPS_7.jpg
    GPS_7.jpg
    42.3 KB · Views: 3,923
  • GPS_8.jpg
    GPS_8.jpg
    33.1 KB · Views: 3,532
  • GPS_9.jpg
    GPS_9.jpg
    52.8 KB · Views: 3,806
  • GPSExampleV2_6.zip
    134.5 KB · Views: 2,031
Last edited:

DonManfred

Expert
Licensed User
Longtime User

ovasquez

Member
Licensed User
Longtime User
Good Night
During the execution of the program the following error occurs when activating MAPS:
This page can not load Google Maps correctly.

The error is given by Line 1082 of Main since the KEY parameter must be included:

HtmlCode = "...... <script type = 'text / javascript' src = 'http: //maps.google.com/maps/api/js? V = 3.exp & sensor = true & key = xxxssdffghh & callback = initMap'> </ script> ........ "

To generate the key, you must create a Google Maps account and activate the "free" testing period. For this they need a credit card, if not is activated, the error will always be shown.

The next URL indicate how must activate the KEY API

https://developers.google.com/maps/documentation/javascript/get-api-key#quick-guide

Regards,

Orlando Vasquez
 

Emerito

Active Member
Licensed User
Longtime User
[QUOTE = "ovasquez, post: 638960, miembro: 41296"] Buenas noches
Durante la ejecución del programa, se produce el siguiente error al activar MAPAS:
Esta página no puede cargar Google Maps correctamente.

El error está dado por la línea 1082 de Main, ya que el parámetro KEY debe incluirse:

HtmlCode = "...... <tipo de script = 'texto / javascript' src = 'http: //maps.google.com/maps/api/js? V = 3.exp & sensor = true & key = xxxssdffghh & callback = initMap '> </ script> ........ "

Para generar la clave, debe crear una cuenta de Google Maps y activar el período de prueba "gratuito". Si no está activada, siempre se verá el error.

La siguiente URL indica cómo se debe activar la API de CLAVE.

https://developers.google.com/maps/documentation/javascript/get-api-key#quick-guide

Saludos

Orlando Vásquez [/ CITA]

good morning,
I'm creating an app where I want to show google maps. Your distribution will be free, but the message appears "This page can not load Google Maps correctly."
The obtaining of the API is free, or when distributing the app would have to pay the license?
 

Roger Daley

Well-Known Member
Licensed User
Longtime User
[QUOTE = "ovasquez, post: 638960, miembro: 41296"] Buenas noches
Durante la ejecución del programa, se produce el siguiente error al activar MAPAS:
Esta página no puede cargar Google Maps correctamente.

El error está dado por la línea 1082 de Main, ya que el parámetro KEY debe incluirse:

HtmlCode = "...... <tipo de script = 'texto / javascript' src = 'http: //maps.google.com/maps/api/js? V = 3.exp & sensor = true & key = xxxssdffghh & callback = initMap '> </ script> ........ "

Para generar la clave, debe crear una cuenta de Google Maps y activar el período de prueba "gratuito". Si no está activada, siempre se verá el error.

La siguiente URL indica cómo se debe activar la API de CLAVE.

https://developers.google.com/maps/documentation/javascript/get-api-key#quick-guide
Below
Saludos

Orlando Vásquez [/ CITA]

good morning,
I'm creating an app where I want to show google maps. Your distribution will be free, but the message appears "This page can not load Google Maps correctly."
The obtaining of the API is free, or when distributing the app would have to pay the license?


Orlando,
Distribution should be free. Below is a link to my Google Maps App based on the same example. I definitely don't pay a licence fee.
https://www.b4x.com/android/forum/threads/antenna-bearing-tool-with-source-code.54073/

Regards Roger
EDIT: This will help but Google makes everything complicated.
https://www.b4x.com/android/forum/threads/google-maps.63930/#content
 

Emerito

Active Member
Licensed User
Longtime User
[QUOTE = "Roger Daley, post: 646014, miembro: 67015"] Orlando,
La distribución debe ser gratuita. A continuación se muestra un enlace a mi aplicación de Google Maps basada en el mismo ejemplo. Definitivamente no pago una licencia.
https://www.b4x.com/android/forum/threads/antenna-bearing-tool-with-source-code.54073/

Saludos Roger
EDITAR: Esto ayudará, pero Google hace que todo sea complicado.
https://www.b4x.com/android/forum/threads/google-maps.63930/#content [/ QUOTE]

He intentado ejecutar su ejemplo, pero me da este error:
B4A Versión: 8.80
Parseando código. (0.05s)
Construcción de estructura de carpetas. (0.02s)
Compilando código. (0.34s)
Compilado códigos de diseños. (0.03s)
Organizando librerías. (0.00s)
Generando el fichero R. Error
ERROR: el directorio de recursos 'c: \ archivos de programa \ android \ android-sdk \ extras \ google \ google_play_services \ libproject \ google-play-services_lib \ res' no existe
 

Roger Daley

Well-Known Member
Licensed User
Longtime User
Orlando,

It appears you have tried to run "AntennaBearingTool2.b4a" from inside the Zip file. Open the Zip Windows Explorer to drag the folder on to the desk top. Open the folder and run "AntennaBearingTool2.b4a".

Regards Roger
 

Emerito

Active Member
Licensed User
Longtime User
android-sdk.png
[QUOTE = "Roger Daley, post: 648843, miembro: 67015"] Orlando,

Parece que ha intentado ejecutar "AntennaBearingTool2.b4a" desde el interior del archivo Zip. Abra el Explorador de Windows Zip para arrastrar la carpeta al escritorio. Abra la carpeta y ejecute "AntennaBearingTool2.b4a".

Saludos Roger [/ CITA]

Buenos dias Roger, Lo he intentado ejecutar desde una carpeta descomprimida, Pero veo que el problema debe estar en esto:
#Recursos adicionales: C: \ Archivos de programa \ Android \ android-sdk \ extras \ google \ google_play_services \ libproject \ google-play-services_lib \ res, com.google.android.gms
y yo no tengo en la carpeta android-sdk la subcarpeta extras
 

Roger Daley

Well-Known Member
Licensed User
Longtime User
View attachment 78155 [QUOTE = "Roger Daley, post: 648843, miembro: 67015"] Orlando,

Parece que ha intentado ejecutar "AntennaBearingTool2.b4a" desde el interior del archivo Zip. Abra el Explorador de Windows Zip para arrastrar la carpeta al escritorio. Abra la carpeta y ejecute "AntennaBearingTool2.b4a".

Saludos Roger [/ CITA]

Buenos dias Roger, Lo he intentado ejecutar desde una carpeta descomprimida, Pero veo que el problema debe estar en esto:
#Recursos adicionales: C: \ Archivos de programa \ Android \ android-sdk \ extras \ google \ google_play_services \ libproject \ google-play-services_lib \ res, com.google.android.gms
y yo no tengo en la carpeta android-sdk la subcarpeta extras


Orlando,

I can only suggest you install the current Android SDK as shown on this link. [And configure paths]

https://www.b4x.com/b4a.html

Regards Roger
 

Emerito

Active Member
Licensed User
Longtime User
en el enlace que me indica he realizado el paso 3 e instalado todo lo recomendado. pero me sigue faltando "\extras\google\google_play_services\libproject\google-play-services_lib\res, com.google.android.gms"
He ejecutado SDK Manager.exe pero no se que es lo que tengo que instalar.
Lamento mi ignorancia. Saludos.
 

Roger Daley

Well-Known Member
Licensed User
Longtime User
en el enlace que me indica he realizado el paso 3 e instalado todo lo recomendado. pero me sigue faltando "\extras\google\google_play_services\libproject\google-play-services_lib\res, com.google.android.gms"
He ejecutado SDK Manager.exe pero no se que es lo que tengo que instalar.
Lamento mi ignorancia. Saludos.



Orlando
It is time to ask the B4A experts. Start a new thread on the Forum about fixing the missing EXIT Folder.
Not having your SDK up to date and working is going to give you lots of problems.

Regards Roger
 

Emerito

Active Member
Licensed User
Longtime User
Little by little I have been taking steps. Now I have the following error

Generando el fichero R. Error
c:\program files (x86)\android\android-sdk\extras\google\google-play-services\libproject\google-play-services_lib\res\values-v21\appinvite_styles.xml:5: error: Error retrieving parent for item: No resource found that matches the given name '@android:style/Theme.Material.Light.DialogWhenLarge.NoActionBar'.
You can help me?
Regards
 
Top