Share My Creation GPS Example

BarrySumpter

Active Member
Licensed User
Longtime User
Back to the original GPS Example.

I'm finding that when I have GPS ON and Map ON as draggable,
my position IS tracking until my position navigates OFF the current map/screen.

When the app needs to load the next map,
it actually recenters on the default location.

I'd like the GPS example app to follow my location onto the next map/screen.

Any help would be greatly appreciated.
 
Last edited:

BarrySumpter

Active Member
Licensed User
Longtime User
OK. Finally got the GPS Sample app to track my location continuously.

I think this was more trial and error than anything else.

Kinda flickers around a bit.
With blank screens between map loads over my amaysim data connection.

My testing:
If I'm at say zoom level 17 (which shows maybe 4 houses circle around my starting location),
when my location changes to where a new map is needed to display,
the zoom changes out to say 14 or maybe 11,
then loads another map
and will change maps correctly as needed.
But often at the zoom level I was on.

The giant arrow as a centre marker was distracting so I chaged it to a small pin. In after thought I would prefer the center marker to be the crosshair and the location marker to be a small green triangle showing heading.

Maybe later.

I'm not sure how much each map download is costing me on a phone network providers data connection like amaysim at $10 per gig.
Which always brings us back to offline storage like Google Maps 5.
So we don't have to pay for the same map download multiple times.

Here is my version of the GPS Sample app with tracking working for me.

If you find a better and/or smoother way please let us know.

Thumbnails show my setup parameters.
With Clickable and Draggable Markers both being OFF as well.

hth
 

Attachments

  • GPSSampleSetup1.png
    70.8 KB · Views: 436
  • GPSSampleSetup2.png
    70.3 KB · Views: 428
Last edited:

BarrySumpter

Active Member
Licensed User
Longtime User
GPSExample v1.6 - BGS3

Track My Location working properly.
With my Setup updates.
I've added a Show Zoom Level cause Zoom level is still bugging me.

hth
 

BarrySumpter

Active Member
Licensed User
Longtime User
Anyone know how I can reference an app asset .png instead of a hyperlink to an icon in Google Maps API v3 html scripting?


B4X:
...
      'HtmlCode = HtmlCode & "; var markerc = new google.maps.Marker({    position: new google.maps.LatLng(" & CenterLat & "," & CenterLng & "),map: map, title: '',clickable: false,icon: 'http://www.google.com/mapfiles/arrow.png' })"
       HtmlCode = HtmlCode & "; var markerc = new google.maps.Marker({    position: new google.maps.LatLng(" & CenterLat & "," & CenterLng & "),map: map, title: '',clickable: false,icon: 'myAppAssetsPath/gpscenter.png' })"
...
something like
B4X:
 myAppAssetsPath = Path(File.DirInternal) & " \images"


Or perhaps I should pull the script for google maps to show center,
and add the centre myself as a transparent panel.
 
Last edited:

BarrySumpter

Active Member
Licensed User
Longtime User
Thanks for the replies.


Waking from a good sleep all I can write is:
Doh! :BangHead:

I think I've even posted about how to do that myself.
Recently.

Burning the candle at both ends.

This code snippet works:

B4X:
Sub Button1_Click

    HtmlCode = "<html><head><meta http-equiv='Content-Type' content='text/html; charset=windows-1252'><title>Test for android asset: gpscenter.png </title></head>"
  HtmlCode = HtmlCode & "<body>Test for android asset: gpscenter.png<p>        <img src='File:///android_asset/gpscenter.png' /></body></html>"

    MapViewer.LoadHtml(HtmlCode)

End Sub
And after 30 different unsuccessful permutations, this seems to work like I want it to:
http://www.b4x.com/forum/basic4android-updates-questions/12573-webview-google-map.html#post71389

B4X:
...
         Dim MyPNG As String
         MyPNG="file:///android_asset/gpscenter.png"
         
       HtmlCode = HtmlCode & "; var markerc = new google.maps.Marker({    position: new google.maps.LatLng(" & CenterLat & "," & CenterLng & "),map: map, title: '',clickable: false,icon:'" & MyPNG & "'})"
 ...
Or perhaps I should pull the script for google maps to show center,
and add the centre myself as a transparent panel.
Since the centre marker actually moves with the map,
I think this should be removed from the map and displayed as centre screen instead of centre map.
Or perhaps make the centre marker invisible if I move the map.
 
Last edited:

BarrySumpter

Active Member
Licensed User
Longtime User
Another update.

Fixed maptouch up that would display a full screen cross hair at touch point and show the lat n lng for 1 second timer.
The lat n lng would show then disappear completely.

I've removed the visible = false and on 1 second timer tick replaced the lat n lng with LastLat n LastLng. i.e. back to currLat n currLng.

The zoom level was always getting set to 12 when CalcMapZoom.
Fixed.

I've left the map centre crosshair instead of the arrow.

The current location is still displayed as another different crosshair.
Change it back to the arrow if you want.

Will probably see if I can change the current location indicator to a direction arrow indicator.

Then display with DrawBitmapRotated to see if I can reflect direction.

Again, all due credit and respect to the original developer, klaus, as this is some really really nice work to begin with.

:sign0098: :sign0188:
 
Last edited:

BarrySumpter

Active Member
Licensed User
Longtime User
Another update.

Have included a direction arrow with heading.

I did try a more accurate real time heading with phone sensors.
But found that when tracking the heading from the phone sensor didn't follow the street as well as the heading from the GPS sensor.
I left the phone sensors script in if you want to experiment.

I'm still finding a lag when on the road downloading maps.
The screen goes blank sometimes for 5 to 10 seconds.
I wonder if there is a technique to load the next map first,
the switch without the blank screen lag.

The direction arrow displays at different sized depending on the heading.
I understand this to be an issue with android.

I think Martin has written a new version of TouchImageView v2.
Where the automatic resize(?) of images has been turned off.
And want to test if I can use the TouchImageView as the direction arrow
instead of an ImageView which resized based upon heading.
 
Last edited:

klaus

Expert
Licensed User
Longtime User
A new update, version 1.70, is available in the first post.
Includes 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 InfoWindow is displayed.

Best regards.
 

Dirk A

Member
Licensed User
Longtime User
Thank you for your very detailed example.
In my application I have to place 3 markers on the map. The coordinates of the markers are constantly changing . I would like to refresh their position every few seconds . The way that I would do it would be to update the MarkerPos list constantly and call MapDisp each time . But is it possible to redraw markers without redrawing the whole map?
If this is allready featured in your code ,could you be so kind to tell me where to look ?

thank you in advance
 

klaus

Expert
Licensed User
Longtime User
I think you need to draw the map each time.
But you could have a look at the possibiliy to use a MapView and Markers (in warwounds' OSMDroid library) to draw the map and perhaps there is a possibility to change the Marker positions without redrawing the map.
I haven't looked yet at MapView but will do in a near future and perhaps change it in the GPSExample.

Best regards.
 

exocet

Member
Licensed User
Longtime User
petit à petit l'oiseau fait son nid

: BangHead:: BangHead: problème de compilation je cherche librairie filedialog?....merci d'avance
 

klaus

Expert
Licensed User
Longtime User
Il semble que tu as des problèmes à trouver les librairies.
Dans le forum sous Additional libraries and official updates il y a un sous forum List of additional librairies dans lequel il y a la liste de toutes les librairies disponibles.
La librairie est la Dialogs librairie.

Meilleures salutations.
 

BarrySumpter

Active Member
Licensed User
Longtime User
Good find.

Offline has been available since v5.
i.e. saving visited maps onto android storage.
And not downloading them again.

But Full offline mapping looks to be as if we will be able to download full maps.
The article didn't mention FREE at all.
Nor open source.

Could be at a cost and propriatary.

Here's hoping.
Can't wait to find out whats on offer.
 
Last edited:

BarrySumpter

Active Member
Licensed User
Longtime User

------
Was testing GPSExample v1.7 and wanted to test my BGS updates but remembered this issue.
Was about to post again to see if any one had a solution yet and mention that this is the only important issue for me
I've had with b4a that was still outstanding.

But, I thought I'd have another go at fixing it.
And was successful.

OK, don't know why/how I got this working nor why/how it was an issue
but this is what I did.
Opened the GPSExample 1.6 project with b4a v1.92.
Changed the PackageName to com.bgs.gpsexample
Tools | Clean Project
Saved Project
closed b4a
opened the project again with b4a v1.92

Commented OUT the following lines:

B4X:
...

Sub Activity_Create(FirstTime As Boolean)


'        If File.Exists(GPSDir, GPSPathFilename) = True Then
'            GPSModule.LoadPath
'        End If

...
And tested successfully.

I can now have GPSExample v1.6 and GPSExample v1.7 and any other variations I've updated installed on the same phone.

Before, since I couldn't change the Package names, all the versions were getting installed on top of the previous one.

But not anymore.

Don't know why this was as issue in the fist place but so relieved I can test this way now.

I do know that the file Test1.GPP and Test2.GPP both have B4A.GPSExample embeded/hardcoded in the top of their binarys.

Might be an indication of where the issue lies? Or not. LOL

hth
 
Last edited:

BarrySumpter

Active Member
Licensed User
Longtime User
Added direction tracking arrow to GPSExample v1.7b

B4X:
    'Enhancements by Barry G. Sumpter
    'bgs - 2012 06 21
    'Added direction tracking arrow
    'Changed package name


Other enhancments I'd like to implement:

connect to GPS at startup
msgbox "Waiting for GPS Location"

show button contol panel at first map display then fade out
fade back in on map touch
etc
 

Attachments

  • GPSExample v1.7b.zip
    135.2 KB · Views: 558
Cookies are required to use this site. You must accept them to continue using the site. Learn more…