Android Question Google Maps Marker Position

tufanv

Expert
Licensed 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
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
 

tufanv

Expert
Licensed User
I dont know how to change the position of marker without clearing and adding again
 

eurojam

Well-Known Member
Licensed User
B4X:
Dim LL As LatLng
LL.Initialize(47.4, 7.188) 'the new Position
myMarker.Position(LL)
 

tufanv

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

tufanv

Expert
Licensed 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)
 

eurojam

Well-Known Member
Licensed 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

tufanv

Expert
Licensed 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 :)
 

eurojam

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