B4J Question [ABMaterial] Need to put some text on ABMGoogleMap Markers

vfafou

Well-Known Member
Licensed User
Longtime User
Hello!

I've just started to develop my first ABMaterial web app.
I'm using ABMGoogleMap to show some markers on it.
The marker images are customised PNGs.
Before showing these markers, I need to draw some dynamic text on them, like canvas.Drawtext in B4A.

Is there any way to do that with ABMaterial?

Thank you in advance!
 
Last edited:

vfafou

Well-Known Member
Licensed User
Longtime User
It seems that may it's difficult, because I have to provide a URL for the PNGs, so it isn't possible to draw a dynamic pin on the map!
 
Upvote 0

vfafou

Well-Known Member
Licensed User
Longtime User
Hi Alain!
Thank you for your response!
I thought that it's may the only way to do that, but I can't figure out how could I draw text on a given image!
 
Upvote 0

vfafou

Well-Known Member
Licensed User
Longtime User
Trying to save the PNG to output stream, I take the following error:
B4X:
java.lang.IllegalStateException: Not on FX application thread; currentThread = main
    at javafx.graphics/com.sun.javafx.tk.Toolkit.checkFxUserThread(Toolkit.java:291)
    at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.checkFxUserThread(QuantumToolkit.java:423)
    at javafx.graphics/javafx.scene.Node.snapshot(Node.java:2191)
    at anywheresoftware.b4j.objects.NodeWrapper.Snapshot2(NodeWrapper.java:353)
    at anywheresoftware.b4j.objects.B4XCanvas.CreateBitmap(B4XCanvas.java:86)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:625)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:168)
    at jdk.internal.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:94)
    at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:61)
    at com.vf.rmweb.rmgooglemap._makefleetpos(rmgooglemap.java:708)
    at com.vf.rmweb.rmgooglemap._fptimer_tick(rmgooglemap.java:699)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:625)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:168)
    at jdk.internal.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:94)
    at anywheresoftware.b4a.objects.Timer$TickTack$1.run(Timer.java:118)
    at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:30)
    at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:26)
    at anywheresoftware.b4a.ShellBA.startMessageLoop(ShellBA.java:115)
    at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:153)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:308)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:168)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:94)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:77)
    at anywheresoftware.b4j.object.JServlet.createInstance(JServlet.java:65)
    at anywheresoftware.b4j.object.BackgroundWorkersManager$1.run(BackgroundWorkersManager.java:21)
    at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:30)
    at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:26)
    at anywheresoftware.b4a.ShellBA.startMessageLoop(ShellBA.java:115)
    at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:153)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:308)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:168)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:94)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:77)
    at com.vf.rmweb.main.main(main.java:29)
The code used is:
B4X:
Sub CreateBitmapWithText (text As String,bcol As Int,ubmp As String)
    Dim img As B4XBitmap = xui.LoadBitmap(File.DirApp & "\images", ubmp)
    Dim cvs As B4XCanvas = CreateCanvas(img.Width, img.Height)
    cvs.DrawBitmap(img, cvs.TargetRect)
    Dim offset As Int = 10
    cvs.DrawText(text, 0, cvs.TargetRect.Height / 2 + offset, xui.CreateDefaultBoldFont(40 / scale), bcol, "CENTER")
    cvs.Invalidate
    Dim out As OutputStream = File.OpenOutput(File.DirApp & "\images", "fff1.png", False)
    cvs.CreateBitmap.WriteToStream(out,100,"PNG")
    out.Close
  
    cvs.Release
End Sub


Private Sub CreateCanvas(width As Int, height As Int) As B4XCanvas
    Dim p As B4XView = xui.CreatePanel("")
    p.SetLayoutAnimated(0, 0, 0, width, height)
    Dim cvs As B4XCanvas
    cvs.Initialize(p)
    Return cvs
End Sub
What is wrong?
 
Last edited:
Upvote 0
Top