B4J Question Googlemaps Marker change position

Roger Daley

Well-Known Member
Licensed User
Longtime User
Hi All,

Next dumb question.

I have a googlemap with 2 markers in the code below a marker is selected:
"gmap_MarkerClick (SelectedMarker As Marker)" and then given a new position with:
gmap_Click (Point As LatLng).

The marker(with Icon) appears correctly at the new location but the icon for the marker remains at the original location.

I have tried removing the icon, used the "Visible" true/false option. o_O

I have searched and no one else seems to have this problem, any idea's?

B4X:
Sub gmap_MarkerClick (SelectedMarker As Marker)
    MarkerFlag = markerMap.Get(SelectedMarker)
    Log (MarkerFlag)
End Sub

Sub gmap_Click (Point As LatLng)
    If MarkerFlag = 1 Then MarkerName1.position = Point
    If MarkerFlag = 2 Then MarkerName2.position = Point
  
    MarkerFlag = 0
End Sub

Regards Roger
 

Roycefer

Well-Known Member
Licensed User
Longtime User
I have had this problem before. I solved it by having the gmap zoom out and then zoom back in really quickly. It's not noticeable to the unaided eye and it forces the gmap to redraw itself (and all the markers and poly-lines) from scratch.
 
Last edited:
Upvote 0

Roger Daley

Well-Known Member
Licensed User
Longtime User
Hi All

As a wrap up to this thread this is the code I used to refresh the map and remove the original marker icon.

Regards Roger.

B4X:
Sub Process_Globals
    Private MapZoom As Float
End Sub

Sub RefreshScreen
    MapZoom = gmap.CameraPosition.Zoom
    MapCenter = gmap.CameraPosition.Target
    cp.Initialize(MapLat, MapLng, (MapZoom/2) )
    gmap.MoveCamera(cp)
    cp.Initialize(MapLat, MapLng, MapZoom )
    gmap.MoveCamera(cp)   
End Sub
 
Upvote 0
Top