Android Question How Put a Label in Google Maps

rafaelmotaquintana

Active Member
Licensed User
I have a google map working fine. I just need to put a label from top left of the map.
I've read that creating a bitmap with the label then add a marker, but I don't know the coordinates, unless the user pulse the map in a long click, and I don't want that.
Any help would be greatly appreciated
 

Attachments

  • Screenshot_2019-08-19.png
    Screenshot_2019-08-19.png
    196.1 KB · Views: 124

DonManfred

Expert
Licensed User
Longtime User
You can place a trasnparent panel over the map.
Use a canvas then to draw on this panel using the panel as canvastarget
WhatsApp Image 2019-08-20 at 14.52.35.jpeg
B4X:
    canvastest.Initialize(pnlcanvas)
    canvastest.DrawText("Testtext",25dip,25dip,Typeface.DEFAULT,20,Colors.Blue,"LEFT")
 
Upvote 0

rafaelmotaquintana

Active Member
Licensed User
I did the snapshot. Then use this code:
B4X:
Sub MapDrawlabel1_SnapshotReady(Bitmap1 As Bitmap)
    Private c As Canvas, b As Bitmap
    b = Bitmap1
    c.Initialize2(b)
    c.DrawText("Testtext",25dip,25dip,Typeface.DEFAULT,20,Colors.Blue,"LEFT")
    Private out As OutputStream
    out = File.OpenOutput(FolderImagesLogo, "MAPA1.png", False)
    b.WriteToStream(out, 100, "PNG")
    out.Close
End Sub

Map is saved. But with no text. Something I'm missing?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
B4X:
Sub Mapextra_SnapshotReady(Bitmap1 As Bitmap)
    Log($"Mapextra_SnapshotReady()"$)
    Dim cvs As Canvas
    cvs.Initialize2(Bitmap1)
    cvs.DrawText("Testtext",25dip,25dip,Typeface.DEFAULT,20,Colors.Blue,"LEFT")

    Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
    Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
  
    Dim Out As OutputStream
    Out = File.OpenOutput(File.DirRootExternal, "Test.png", False)
    cvs.Bitmap.WriteToStream(Out, 100, "PNG")
    Out.Close
End Sub
 
Last edited:
Upvote 0
Top