Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4android > Basic4android Share Your Creations
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Basic4android Share Your Creations Show your creations. Please upload source code if possible. You can use File - Export As Zip to create the zip file.
The first attached image will be displayed as the thread preview image.

GPS Example

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-19-2011, 08:56 AM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 4,461
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default 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
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
It is designed for smartphones and does work only in portrait mode.

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

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
Attached Thumbnails
GPS Example-gps_1.jpg  GPS Example-gps_2.jpg  GPS Example-gps_3.jpg  GPS Example-gps_4.jpg  GPS Example-gps_5.jpg  

GPS Example-gps_6.jpg  GPS Example-gps_7.jpg  GPS Example-gps_8.jpg  
Attached Files
File Type: zip GPSExample_1_60.zip (115.5 KB, 731 views)
__________________
Klaus
Switzerland

Beginner's Guide / User's Guide

Last edited by klaus : 05-23-2012 at 07:35 AM.
Reply With Quote
  #2 (permalink)  
Old 12-19-2011, 09:59 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,689
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

Thank you Klaus for this excellent example.
Reply With Quote
  #3 (permalink)  
Old 12-19-2011, 11:56 AM
Knows the basics
 
Join Date: Feb 2011
Location: Sydney, Australia
Posts: 66
Default

Thanks for providing such a complete example showing much more than just how to access GPS.

bluejay
Reply With Quote
  #4 (permalink)  
Old 12-19-2011, 07:49 PM
Merlot2309's Avatar
Basic4ppc Veteran
 
Join Date: Feb 2009
Location: Spain
Posts: 293
Default

Hi Klaus,

What a beauty of an example and I do appreciate it so much that you share it here.

Very best regards,
Helen.
__________________
IPhone 4 - HTC Legend - HTC Touch Diamond 2
Android 2.2 Tablet 10.2" (Chinese Superpad 3)
Reply With Quote
  #5 (permalink)  
Old 12-19-2011, 07:59 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 2,344
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

Hi Klaus

Despite being YOU the Birthday boy, it's US who get the present!!! Thanks!!!!

I have one request:

Is it possible to draw a "Navigator" like path, from the actual device position to a marker?
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)

My Posts helped you? Consider Buying me a Porto Glass!
Reply With Quote
  #6 (permalink)  
Old 12-19-2011, 08:16 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 4,461
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

Hi Paulo,
Quote:
Is it possible to draw a "Navigator" like path, from the actual device position to a marker?
I'm afraid no, it could be possible to draw a straight line from the current point to a marker, but as I don't know any vertice of the roads I can't draw a Navigator path.

Best regards.
__________________
Klaus
Switzerland

Beginner's Guide / User's Guide
Reply With Quote
  #7 (permalink)  
Old 12-19-2011, 09:00 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 2,344
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

Am I right to think tha the Google Navigator uses the same engine as the Google Maps?

If so, would it be possible to replace the "google maps" portion of the app with the navigator one?...

Hope I am being clear enought...
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)

My Posts helped you? Consider Buying me a Porto Glass!
Reply With Quote
  #8 (permalink)  
Old 12-19-2011, 09:14 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 2,344
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

Just found a very interesting page regarding the Directions API within the main MAPS API...

I believe that making a Library to simplify the most frequent/usefull functions of these API would be a HUGE task...
Anyone up to the challenge??
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)

My Posts helped you? Consider Buying me a Porto Glass!
Reply With Quote
  #9 (permalink)  
Old 12-20-2011, 06:02 AM
Junior Member
 
Join Date: Sep 2011
Posts: 23
Default

Hi Klaus
Thank you for this excellent example.But I didnt compaile B4A give error Sub not declare...
Ahmet
Reply With Quote
  #10 (permalink)  
Old 12-20-2011, 06:11 AM
Senior Member
 
Join Date: Apr 2007
Location: Arlington, Washington USA
Posts: 180
Default

Klaus, you may have noticed that in a recent update to my GPSlog program, I added mapping for the current location and for stored locations. I found an unexpected difference in behavior between the program running on my Motorola Droid 2, and my Acer Iconia a500 tablet. On the phone, the zoom control is displayed as expected, but on the tablet the zoom control is missing. I loaded your GPS example on both of my devices, enabled the zoom control on both, and tested it. I got the same result: no zoom control on the tablet. Any ideas why this is?

Another small problem with your example program is that I also enabled the map type control, and on the phone the Altitude label sits on top of the type control, making that control difficult to read.

Another strange behavior is this. On both devices (phone and tablet) with the zoom and map type controls enabled, the initial map view when switched to satellite view is at the default zoom level. When I click on the setup icon, change nothing, click back on the map icon the display is at maximum zoom.

The last two items should be easy to fix, but the missing zoom control on the table has be stumped at the moment.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On


All times are GMT. The time now is 10:43 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0