Android Question Marker not showing on Google Maps

Declan

Well-Known Member
Licensed User
Longtime User
I have a panel which has a MapFragment.
The following code displays the map, but the marker is not placed on the map?
Code::
Sub OpenMap_Click
    LoadMap("-25.855718", "28.179536", "5.1", "200C1BD")
End Sub
    


Sub LoadMap(Lat As String, Lon As String, Volts As String, deviceID As String)
    pnlMap.Visible = True
    Wait For MapFragment1_Ready
    gmap = MapFragment1.GetMap
    rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
    Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
    If Result Then
        gmap.MyLocationEnabled = True
    Else
        Log("No permission!")
    End If
    
    gmap.AddMarker(Lat, Lon, "ALARM: " & deviceID & " " & Volts & "V")
    
    Dim cp As CameraPosition
    cp.Initialize(Lat, Lon, 15)
    gmap.AnimateCamera(cp)
    
End Sub
 

DonManfred

Expert
Licensed User
Longtime User
I have a panel which has a MapFragment.
I can not see you are loading the layout.

MapFragment1_Ready raises after you load the layout to the panel and the map is ready....

Upload a small project showing the problem.
 
Upvote 0

Declan

Well-Known Member
Licensed User
Longtime User
I can not see you are loading the layout.

MapFragment1_Ready raises after you load the layout to the panel and the map is ready....

Upload a small project showing the problem.
Hi,
Attached is the ZIP file
 

Attachments

  • HB.zip
    31.3 KB · Views: 153
Upvote 0

RichardN

Well-Known Member
Licensed User
Longtime User
I have found manipulating the map after a WaitFor to be unpredictable. You can do that as suggested by @DonManfred by putting that code in the MapFragment1_Ready event.

It may be more convenient to load the map at the start of the program but keep it hidden until you actually need to use it.

The variables of Lat and Long should be Double not String. That may be the reason for the marker being off the Camera view
 
Last edited:
Upvote 0
Top