GPS: Display Map of Site Where Latitude, Longitude are Stored in SQLite Table

Mahares

Expert
Licensed User
Longtime User
I have a SQLite table with 4 fields: SITE, LATITUDE, LONGITUDE, ELEVATION. Example:lat=39.70433406, long=-75.858289, elev=1764 ft.
Here is what I want to achieve: Before driving to the field site a tech displays the list of sites from the above table in a listview, then selects a site. Immediately a map displays the location and/or driving directions to the selected field site based on its coordinates. I read many of the GPS threads and samples, but failed to come up with something that seems so simple.
Thank you for any guidance.
 
Last edited:

NJDude

Expert
Licensed User
Longtime User
You could try opening Google Navigation/Maps, etc via an intent like this:
B4X:
Dim MapIntent As Intent
                     
Selection = "geo:0,0?q=" & "39.70433406, -75.858289" '<-- This of course will be variables you read from your DB
      
MapIntent.Initialize(MapIntent.ACTION_VIEW, Selection)
      
StartActivity(MapIntent)
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
@NJDude: You are terrific. You steered me in the right direction. I hope you weathered the big storm.
The majority of the sites are in remote rural area and the map does not show too many details. What I was hoping to achieve, is that the device/phone detects the technician location and then, displays the spelled out directions to the remote site he/she selected from the listview.
Thank you
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
When the GPS is enabled, the map gives me the option to display directions from my location to the remote site which works well.
But my hope was that, as soon as I select a site from the listview, the directions show up from my site to the remote site before the map shows up to reduce the steps to go directly to the directions as they are more useful than the map. In other words, bypass the map and display spelled out directions. This is where I am stuck.
Thank you
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
Ok, try this:
B4X:
Dim MapIntent As Intent
Selection = "google.navigation:q=" & "39.70433406, -75.858289"
MapIntent.Initialize(MapIntent.ACTION_VIEW, Selection)

StartActivity(MapIntent)

Then on the Menu bar there's button that by tapping on it you'll get the "written" directions, I don't know if it is possible to display that directly

I hope you weathered the big storm.

Yes, it was scary for a while, the house swinging, trees and debris flying but nothing major happened in my area.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
@NJDude: That works great. Both options work well. You are correct, you cannot get the directions right off the bat, but clicking an icon on the menu bar is not an inconvenience.
OPTION1:
B4X:
Selection = "google.navigation:q=" & "39.70433406, -75.858289"
OPTION2:
B4X:
Selection = "geo:0,0?q=" & "39.70433406, -75.858289"
I am glad you fared well after that horrific storm. I am in your neighboring state (western part). We got a lot of rain, but no major damage.
Again, than you very much for your assistance.
 
Upvote 0
Top