Share My Creation GPS Example

BarrySumpter

Active Member
Licensed User
Longtime User
Added Map Explore mode to GPSExample v1.7c

When tracking current location with GPS on and Map on,
if the map is touched and moved,
GPS is Stopped and a Reposition to current location icon is displayed in the bottom left corner
and you can wonder around moving the map without tracking back etc.
Touch the Reposition to Current Location icon and your back to tracking current location.

.
 

Attachments

  • GPSExample v1.7c.zip
    135.6 KB · Views: 620
Last edited:

BarrySumpter

Active Member
Licensed User
Longtime User
Please help debug - can't get gps to turn OFF

'bgs - 2012 06 22
' Added Auto GPS On - via btnGPS_Touch() in one second startup Timer
' Added Auto Map ON - via btnMap_Touch() in GPS1_LocationChanged


Solved GPS not stopping with the 1 second timer

.
 

Attachments

  • GPSExample v1.7d.zip
    136.5 KB · Views: 557
Last edited:

BarrySumpter

Active Member
Licensed User
Longtime User
GPSExample v1.7e

'bgs - 2012 06 24
' ToolBox - Fade In and Fade Out using timers
' added ICOSFadeAnimation library
'
' Set Map_On to False on app exit
' - otherwise, if map_on at app exit, Map will auto display 0,0 As lat,lng on restart

.
 

Attachments

  • GPSExample v1.7e.zip
    138.1 KB · Views: 542

BarrySumpter

Active Member
Licensed User
Longtime User
GPSExample v1.7f

'bgs - 2012 06 25
' Timer - Stop GSP if Location hasn't changed in x mins
' to save on battery

.
 

Attachments

  • GPSExample v1.7e.zip
    138.1 KB · Views: 548

BarrySumpter

Active Member
Licensed User
Longtime User
'Enhancements by Barry G. Sumpter

'bgs - 2012 06 26
' Finally - found a way to force GPS off and Map off on exit

.
 

Attachments

  • GPSExample v1.7f.zip
    137.4 KB · Views: 587
Last edited:

BarrySumpter

Active Member
Licensed User
Longtime User
Hi Klaus,

Is there a way to update the webview with a FishishedLoading event?

Each time the webview loads a new map there is a two to three second blank screen
with only the DirectionArrow.

I want to hide he Direction Arrow between screens.

Also, I'm thinking to reduce the blank between screens,
we could toggling visible between two webviews.
 
Last edited:

klaus

Expert
Licensed User
Longtime User
Hi Barry,
You can add in the MapDisp routine the lines below just before If MapSetDraggable = False to add the 'tilesloaded' event.
B4X:
' adds tilesloaded event
HtmlCode = HtmlCode & ";google.maps.event.addListener(map, 'tilesloaded', function(){"
HtmlCode = HtmlCode & "B4A.CallSub('MapViewer_TilesLoaded', true); })"

If MapSetDraggable = False Then
And add following routine:
B4X:
Sub MapViewer_TilesLoaded
    ToastMessageShow("Tiles loaded", False)
    ' replace ToastMessageShow by your code
End Sub
Using two WebView views could be done.
On way would be to transmit to the MapDisp routine the WebView to update as a parameter and manage the two WebViews in the code. That way the MapDisp routine remains almost the same just one more parameter and change of the last but one line. The two WebViews could be an array.
Or to define a third webview variable containing the current active WebView.
For example: the two WebViews MapViewer1 and MapViewer2 and the third variable MapViewer. In that case the MapDisp routine remains the same as it uses MapViewer.LoadHtml. And set MapViewer = MapViewer1 or MapViewer = MapViewer2 to set the webview to update.

Best regards.
 

BarrySumpter

Active Member
Licensed User
Longtime User
Thanks for the verbose response Klaus.
Much appreciated.

I think I see where you're heading.

Where the rest of the script behind the original webview would remain static as needed to function as usual.

So instead of toggling the visibility between the two webviews,
I should simply have a webView2 for loading the page only.
With no further functionality behind webView2.

While the original webView displays the previuos page until
the webView2 is finished loading
then
MapViewer = MapViewer2

Which should cut down on the blank screen between page loads.

I'll see what trouble I can get into.

Many thanks.
 

BarrySumpter

Active Member
Licensed User
Longtime User
...
And set MapViewer = MapViewer1 or MapViewer = MapViewer2 to set the webview to update.
...

Can't seem to get this to work.
Is there another way to assign this that will work with the HTML?

Unless I can have both MapViewer and MapView2 point to the same events?
hmmmm.
 
Last edited:

BarrySumpter

Active Member
Licensed User
Longtime User
'bgs - 2012 06 28
' Added TilesLoaded Listener function event to WebView
' to trap when WebView has finished loading
'
' Added MapView2 and toggle logic to fix / shorten blank screens on map change
'

A lot of trial and error.
The resulting script looks too easy.

Back to my original idea to toggle visible between MapViews.
Since I can have both mapViewers point to the same events.


Thanks for all the help Klaus!

----

update
'bgs - 2012 06 29
' Toggling mapViewers not working correctly. Fixed in various places


Still not perfect.
Direction arrow displaying in wrong place just before map change

Getting closer.

Any help from anyone would be grealy appreciated.

.
 

Attachments

  • GPSWxample v1.7h.zip
    138.4 KB · Views: 616
Last edited:

wm.chatman

Well-Known Member
Licensed User
Longtime User
Hello Klaus

This is of course a great example and I appreciate it very much that you have shared it here for other users also. The UI looks Great!
One request for your GPS Example. The App uses the internal GPS of the Phone!
And as I have found out, the Power of the Phone goes down pretty fast, using it. Is it at all possible to add a external Bluetooth Unit? This way a User has a choise between internal or external GPS. A external Bluetooth Unit would last a bit longer, when App is in use. Is this possible for you to add on?
 

klaus

Expert
Licensed User
Longtime User
I'm afraid that this would be more complicated here than in Basic4PPC.
Basic4PPC has a library manageing both the internal external GPS devices this is not the case in Basic4Android.
So you need to:
- manage the connection of the external GPS device
- fetch the GPS data
- extract the needed data.

I don't know if all external GPS devices send the same data and I don't have one.

Best regards.
 

BarrySumpter

Active Member
Licensed User
Longtime User
Hay Chatman,
I've added a 5 min timer to one of these versions to address the battery drain from the GPS.
Post #125.

Hope it helps.
 
Last edited:

wm.chatman

Well-Known Member
Licensed User
Longtime User
Hello Barry

OK got it. Could you maybe add somthing also to your App, to accsess the external Bluetooth??? This would really be great.
The external Bluetooth Unit I own works 8 plus hours, and is also a better option. Would you do this for me Barry???
Like I wrote Klaus: maybe to have a choice between the two. Either use internal, or use external. Would really be cool.
@ Klaus. Been reading about the Bluetooth deal, but I really dont know where to start, nor where to put all that code.
 
Last edited:

BarrySumpter

Active Member
Licensed User
Longtime User
Its not my app at all.
I've just posted a few enhancements.
In comparison to the major contributors to b4a I'm a newbie hack.
All my work is based on their contributions and advice.
So all do respect and credit to b4a creators, contributors and developers.

I've attempted to solve the GPS drain issues with the 5 min timer.
So no extrenal battery nor GPS needed.

So my humble suggestion is to keep it simple as the creators and contributors of b4a encourage.

However, if you do decide to persue this subject
perhaps a bit more research on which libraries you might be able to use
then post a query in a new thead asking for advice based upon your reseach.

hth
 
Last edited:

wm.chatman

Well-Known Member
Licensed User
Longtime User
Hello BarrySumpter

I ought to have typed your enhancements, instead of your "App".
My misstake, it's a typing typo error. Did not mean to offend, if I did so.
And yes, all respect and credit to b4a creators, contributors and developers!

The "enhancements" are also great.
 

BarrySumpter

Active Member
Licensed User
Longtime User
Hi klaus,
Would you have an opinion on using the Location Manager Library as an alternative?
As I've mentioned before my GPS location drives me mad taking so long to discover when sitting at my PC and in various locations mentioned.

http://www.b4x.com/forum/additional.../13337-locationmanager-library.html#post75151

Could we implement in latest GPS Example?

Or perhaps point me in the right direction to get me started?
 
Last edited:

klaus

Expert
Licensed User
Longtime User
I could have a look at it but unfortunately not before a week, I will be absent till next saturday.
I have never used the Location Manager Library yet so I need to learn it first too before using it. And so difficult to give you any direction right now.
I put it on my to do list.

Best regards.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…