Android Question Google Maps Marker Position

tufanv

Expert
Licensed User
Longtime User
Hello,

I want to show my cars current position on google map so with gps_locationchanged event I am clearing the gmap and adding the marker. But visually this is not good. With every position change marker clears then added again. How can i change the markers position with the cars new position. ( i dont want to clear and add again but change the marker position with the car)

TY
 

eurojam

Well-Known Member
Licensed User
Longtime User
Have you tried to put the marker to a map or list (in the MapFragment1_Ready sub) and then get it back in the gps_locationchanged event - like mymarker = list1.get(0) - and then set the new position instead of clearing the map and add it again

cheers
stefan
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
Ok . I could initialize with
mymarker=gmap.AddMarker2(location1.Latitude, location1.Longitude, "My Position", gmap.HUE_ORANGE)
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
ı have another problem now . When maps get my location and sets the camera position according to it. maps are not fully loaded(it is blurry) until i move the position a bit. my code is as below:
B4X:
  mymarker=gmap.AddMarker3(location1.Latitude, location1.Longitude, "My Position",ikon)
    Dim LL As LatLng
LL.Initialize(location1.Latitude,location1.Longitude)
mymarker.Position = LL
    cp.Initialize(location1.Latitude,location1.Longitude,15)
    gmap.AnimateCamera(cp)
 
Upvote 0

eurojam

Well-Known Member
Licensed User
Longtime User
TY,
your project seems to work. I have made some small changes, like using the OnMyLocationChangeListener Event from GoogleMapsExtra - so you don't need a GPS for the location change event which is helpful because I am developing not outside :D, I replaced your icon because adam.png yok...

Cheers
stefan
 

Attachments

  • pin_stefanda.zip
    13.5 KB · Views: 291
Upvote 0

tufanv

Expert
Licensed User
Longtime User
TY,
your project seems to work. I have made some small changes, like using the OnMyLocationChangeListener Event from GoogleMapsExtra - so you don't need a GPS for the location change event which is helpful because I am developing not outside :D, I replaced your icon because adam.png yok...

Cheers
stefan

With my icon, Now there are 2 markers. One is the standard blue dot and other one is adam.png ( icon) how can i remove the blue one here :)
 
Upvote 0

eurojam

Well-Known Member
Licensed User
Longtime User
put this to comment:
B4X:
'mFragment.GetMap.MyLocationEnabled = True
and uncomment the sub GPS_LocationChanged
 
Upvote 0
Top