Android Question GPS location latitude longitude

anaylor01

Well-Known Member
Licensed User
Longtime User
I can't seem to get the lat and long.
If FirstTime Then
gps1.Initialize("GPS")
loc1.Initialize
loc2.Initialize
End If
lat = loc1.Latitude
Long1 = loc1.Longitude
Msgbox(lat & " Lat " & Long1 & " long1", "Loc")
 

anaylor01

Well-Known Member
Licensed User
Longtime User
I have this
lat = loc1.Latitude
Long1 = loc1.Longitude
Msgbox(lat & " Lat " & Long1 & " long1", "Loc")
in the gps changed routine and it only shows 0.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
You must show the whole code of the routine.
It's difficult to give a concrete advice with small code snippets, we need to guess what you have done and how.
Try this:
B4X:
Sub GPS+_LocationChanged(Location1 As Location)
    MsgBox(Location1.Latitude & " Lat " & Location1.Longitude & " long1", "Loc")
End Sub
Do you try it insides ?
GPS works only outsides.
 
Upvote 0

anaylor01

Well-Known Member
Licensed User
Longtime User
That worked. It must be the data types. I have them as double. Should they be something else?
 
Upvote 0

anaylor01

Well-Known Member
Licensed User
Longtime User
I did and that is what I made them so I think it is that I had them named loc1.latitude and loc1.longitude.
 
Upvote 0

anaylor01

Well-Known Member
Licensed User
Longtime User
Ok here is my problem now. When I try to zoom on the map it keeps resetting because following code is in the gps location change sub. Also I want to use the typical red stick pin to report location.

MapCenter.Initialize(Location1.Latitude, Location1.Longitude)
ZoomLevel=25
MapView1.Zoom=ZoomLevel
MapView1.SetCenter3(MapCenter)
 
Upvote 0

anaylor01

Well-Known Member
Licensed User
Longtime User
What I am trying to do should be pretty simple to someone who knows what they are doing. I basically just want to display a small map with a marker of the users current location. That's it.
 
Upvote 0

anaylor01

Well-Known Member
Licensed User
Longtime User
I can't get a marker to show up. here is my code. Some of it is commented out because I have tried those ways also.
Sub GPS_LocationChanged (Location1 As Location)
MapCenter.Initialize(Location1.Latitude, Location1.Longitude)
' mark.Initialize("title","descr",MapCenter.Latitude, MapCenter.Longitude,Null)
mark.Initialize("title","descr",Location1.Latitude, Location1.Longitude,Null)
ZoomLevel=25
MapView1.Zoom=ZoomLevel
MapView1.SetCenter3(MapCenter)
End Sub
 
Upvote 0

anaylor01

Well-Known Member
Licensed User
Longtime User
Can someone help?
Sub GPS_LocationChanged (Location1 As Location)
Dim bm_user As BitmapDrawable
bm_user.Initialize(LoadBitmap(File.DirAssets, "Pointer.jpg"))
'lblLat.Text = "Lat = " & Location1.ConvertToMinutes(Location1.Latitude)
'lblLon.Text = "Lon = " & Location1.ConvertToMinutes(Location1.Longitude)
'Msgbox(Location1.Latitude & " Lat " & Location1.Longitude & " long1", "Loc")
MapCenter.Initialize(Location1.Latitude, Location1.Longitude)

' mark.Initialize("title","descr",MapCenter.Latitude, MapCenter.Longitude,Null)
mark.Initialize("title","descr",Location1.Latitude, Location1.Longitude,bm_user)

ZoomLevel=25
MapView1.Zoom=ZoomLevel
MapView1.SetCenter3(MapCenter)
 
Upvote 0

Mark Read

Well-Known Member
Licensed User
Longtime User
Hello anaylor01, maybe I can help a little. I am working on a project with OSMdroid and gps. My code is not yet complete but the map changes according to the gps coordinates, which is what you want I think. No layout file is required. The camera part is commented out. If you turn it on, the map may not work.
You will need the following libraries:
Camera 2.20
Core 2.71
GPS 1.11
OSMDroid 3.53
Phone 2.10
Reflection 2.40

Hope this helps. Regards
Mark
 

Attachments

  • Project1-10.zip
    45.7 KB · Views: 400
Upvote 0

anaylor01

Well-Known Member
Licensed User
Longtime User
Thanks Mark but yours does the same as mine or the opposite of mine. Yours shows the marker but no map. Mine shows the map but no marker.
 
Upvote 0

Mark Read

Well-Known Member
Licensed User
Longtime User
Strange because it works form me on my samsung galaxy tab 10 and on my emulator running API 8! Note, the only map source which works is MapquestOSM, none of the others work with me.

Regards
Mark
 
Upvote 0
Top