Jul 30, 2015 Replies: 106 The latest version of Google Maps isn't compatible with JavaFX WebView. Don't use this library. Alternative solution: https://www.b4x.com/android/forum/threads/jsd_openmaps.166066/#content This library is similar to B4A and B4i GoogleMaps libraries. It is based on this open source project: https://github.com/dlsc-software-consulting-gmbh/GMapsFX/ (Apache 2 license). Under the hood it uses JavaFX WebView with GoogleMaps JavaScript API V3. Using the map is quite simple. You need to initialize GoogleMap and then wait for the Ready event. GoogleMap.AsPane returns the pane that holds the map. You should add this pane to the nodes tree. Once the ready event is fired you can add markers or change the position. Updates: V2.01 - Sets the Google Maps Javascript SDK version to 3.56. There is currently an issue with JavaFX and Google Maps v3.57. A big thank you to @Star-Dust for helping with solving this issue! V2.00 - Depends on OpenJDK 19. Previous versions will not work. 1. OpenJDK 19.0.2 + OpenJFX 17.0.6: https://www.b4x.com/b4j/files/jdk-19.0.2.7z 2. Add to main module: Code: #PackagerProperty: IncludedModules = javafx.web #PackagerProperty: AdditionalModuleInfoString = exports com.lynden.gmapsfx; exports com.lynden.gmapsfx.javascript; exports com.lynden.gmapsfx.javascript.event; #PackagerProperty: AdditionalModuleInfoString = exports com.lynden.gmapsfx.javascript.object; exports com.lynden.gmapsfx.service.directions; exports com.lynden.gmapsfx.service.elevation; #PackagerProperty: AdditionalModuleInfoString = exports com.lynden.gmapsfx.service.geocoding; exports com.lynden.gmapsfx.shapes; exports com.lynden.gmapsfx.zoom; 3. Add reference to jOkHttpUtils2. Tip: to fix logging encoding issues with Java 19+, add this: Code: #VirtualMachineArgs: -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 #PackagerProperty: VMArgs = -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 The standalone package will not work without steps 2 and 3. Attachments GoogleMapExample.zip GoogleMapExample.zip 2.8 KB · Views: 1,053 jGoogleMaps.zip jGoogleMaps.zip 199.3 KB · Views: 872 Last edited: May 22, 2025 Click to expand...
The latest version of Google Maps isn't compatible with JavaFX WebView. Don't use this library. Alternative solution: https://www.b4x.com/android/forum/threads/jsd_openmaps.166066/#content This library is similar to B4A and B4i GoogleMaps libraries. It is based on this open source project: https://github.com/dlsc-software-consulting-gmbh/GMapsFX/ (Apache 2 license). Under the hood it uses JavaFX WebView with GoogleMaps JavaScript API V3. Using the map is quite simple. You need to initialize GoogleMap and then wait for the Ready event. GoogleMap.AsPane returns the pane that holds the map. You should add this pane to the nodes tree. Once the ready event is fired you can add markers or change the position. Updates: V2.01 - Sets the Google Maps Javascript SDK version to 3.56. There is currently an issue with JavaFX and Google Maps v3.57. A big thank you to @Star-Dust for helping with solving this issue! V2.00 - Depends on OpenJDK 19. Previous versions will not work. 1. OpenJDK 19.0.2 + OpenJFX 17.0.6: https://www.b4x.com/b4j/files/jdk-19.0.2.7z 2. Add to main module: Code: #PackagerProperty: IncludedModules = javafx.web #PackagerProperty: AdditionalModuleInfoString = exports com.lynden.gmapsfx; exports com.lynden.gmapsfx.javascript; exports com.lynden.gmapsfx.javascript.event; #PackagerProperty: AdditionalModuleInfoString = exports com.lynden.gmapsfx.javascript.object; exports com.lynden.gmapsfx.service.directions; exports com.lynden.gmapsfx.service.elevation; #PackagerProperty: AdditionalModuleInfoString = exports com.lynden.gmapsfx.service.geocoding; exports com.lynden.gmapsfx.shapes; exports com.lynden.gmapsfx.zoom; 3. Add reference to jOkHttpUtils2. Tip: to fix logging encoding issues with Java 19+, add this: Code: #VirtualMachineArgs: -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 #PackagerProperty: VMArgs = -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 The standalone package will not work without steps 2 and 3.
R rboeck Well-Known Member Licensed User Longtime User Mar 20, 2017 #81 It's not possible, to write this code: Dim Point as Latlng Point.Latitude=12 (Property: Latitude is readonly) In B4A and i think in all older versions of jgooglemaps.jar it was possible.
It's not possible, to write this code: Dim Point as Latlng Point.Latitude=12 (Property: Latitude is readonly) In B4A and i think in all older versions of jgooglemaps.jar it was possible.
Erel B4X founder Staff member Licensed User Longtime User Mar 20, 2017 #82 rboeck said: In B4A and i think in all older versions of jgooglemaps.jar it was possible. Click to expand... That's not correct. These properties are write only in B4A and in previous versions of jGoogleMaps.
rboeck said: In B4A and i think in all older versions of jgooglemaps.jar it was possible. Click to expand... That's not correct. These properties are write only in B4A and in previous versions of jGoogleMaps.
gvoulg Member Licensed User Longtime User Mar 20, 2017 #83 Marker .remove and .label no longer exists. Can we also have the latest version that supports them ? George
Marker .remove and .label no longer exists. Can we also have the latest version that supports them ? George
Erel B4X founder Staff member Licensed User Longtime User Mar 21, 2017 #84 You need to use GoogleMap.RemoveMarker (this change is related to a change in GMapFX). What is the difference between Marker.Label and Marker.Text ?
You need to use GoogleMap.RemoveMarker (this change is related to a change in GMapFX). What is the difference between Marker.Label and Marker.Text ?
Erel B4X founder Staff member Licensed User Longtime User Mar 22, 2017 #86 You can use this code: Code: Sub SetMarkerLabel(m As Marker, text As String) Dim r As Reflector 'jReflection library r.Target = m r.RunMethod4("invokeJavascript", Array("setLabel", Array(text)), Array As String("java.lang.String", "[Ljava.lang.Object;")) End Sub
You can use this code: Code: Sub SetMarkerLabel(m As Marker, text As String) Dim r As Reflector 'jReflection library r.Target = m r.RunMethod4("invokeJavascript", Array("setLabel", Array(text)), Array As String("java.lang.String", "[Ljava.lang.Object;")) End Sub
Pedro Caldeira Active Member Licensed User Longtime User Mar 27, 2017 #87 I Get an error just by running the example, after a few seconds I get the following Error. Code: Waiting for debugger to connect... Program started. Error occurred on line: 64 (Main) java.lang.NullPointerException at com.lynden.gmapsfx.javascript.object.GoogleMap.internalGetZoom(GoogleMap.java:76) at com.lynden.gmapsfx.javascript.object.GoogleMap.zoomProperty(GoogleMap.java:93) at com.lynden.gmapsfx.javascript.object.GoogleMap.setZoom(GoogleMap.java:68) at anywheresoftware.b4j.objects.GoogleMapWrapper.MoveCamera(GoogleMapWrapper.java:219) at b4j.google.map.main._btnresetmap_action(main.java:161) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:612) at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:226) at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93) at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90) at anywheresoftware.b4a.BA$2.run(BA.java:165) at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191) at java.lang.Thread.run(Thread.java:745)
I Get an error just by running the example, after a few seconds I get the following Error. Code: Waiting for debugger to connect... Program started. Error occurred on line: 64 (Main) java.lang.NullPointerException at com.lynden.gmapsfx.javascript.object.GoogleMap.internalGetZoom(GoogleMap.java:76) at com.lynden.gmapsfx.javascript.object.GoogleMap.zoomProperty(GoogleMap.java:93) at com.lynden.gmapsfx.javascript.object.GoogleMap.setZoom(GoogleMap.java:68) at anywheresoftware.b4j.objects.GoogleMapWrapper.MoveCamera(GoogleMapWrapper.java:219) at b4j.google.map.main._btnresetmap_action(main.java:161) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:612) at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:226) at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93) at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90) at anywheresoftware.b4a.BA$2.run(BA.java:165) at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191) at java.lang.Thread.run(Thread.java:745)
Matias Ferrer Member Licensed User Longtime User Mar 28, 2017 #88 Hello everyone. I have a problem with jGoogleMaps with my application and also with the example application of the library. After running the application, I wait for 5 seconds and the following error message appears: "Oops! Something went wrong. This page did not load Google Maps correctly. See the JavaScript console for technical details. " I have updated the version of jGoogleMaps to 1.55 and my version of java to 1.8.0.121. The error continues Someone can help me. Thank you!
Hello everyone. I have a problem with jGoogleMaps with my application and also with the example application of the library. After running the application, I wait for 5 seconds and the following error message appears: "Oops! Something went wrong. This page did not load Google Maps correctly. See the JavaScript console for technical details. " I have updated the version of jGoogleMaps to 1.55 and my version of java to 1.8.0.121. The error continues Someone can help me. Thank you!
Erel B4X founder Staff member Licensed User Longtime User Mar 28, 2017 #89 Pedro Caldeira said: I Get an error just by running the example, after a few seconds I get the following Error. Click to expand... Please start a new thread for this.
Pedro Caldeira said: I Get an error just by running the example, after a few seconds I get the following Error. Click to expand... Please start a new thread for this.
Pedro Caldeira Active Member Licensed User Longtime User Mar 28, 2017 #90 Hi Erel, FYI have update the jdk to version 1.8.0_121 and I no longer have that error. Thanks.
Pedro Caldeira Active Member Licensed User Longtime User Mar 28, 2017 #91 Had the same error again. No apparent reason. On minute is working, the other is not. Going to open another thread.
Had the same error again. No apparent reason. On minute is working, the other is not. Going to open another thread.
B bvonlaar Member Licensed User Longtime User Apr 17, 2017 #92 Erel said: You can use this code: Code: Sub SetMarkerLabel(m As Marker, text As String) Dim r As Reflector 'jReflection library r.Target = m r.RunMethod4("invokeJavascript", Array("setLabel", Array(text)), Array As String("java.lang.String", "[Ljava.lang.Object;")) End Sub Click to expand... Hi, it works fine, but how can I change the color of the "text" Benedikt
Erel said: You can use this code: Code: Sub SetMarkerLabel(m As Marker, text As String) Dim r As Reflector 'jReflection library r.Target = m r.RunMethod4("invokeJavascript", Array("setLabel", Array(text)), Array As String("java.lang.String", "[Ljava.lang.Object;")) End Sub Click to expand... Hi, it works fine, but how can I change the color of the "text" Benedikt
Erel B4X founder Staff member Licensed User Longtime User Apr 17, 2017 #93 Please start a new thread for this question.
R RichardHirst Member Licensed User Longtime User Jun 26, 2017 #94 Hello Erel Is there any 'off-line' cache settings..? Thanks Richard
Erel B4X founder Staff member Licensed User Longtime User Jun 26, 2017 #95 Please start a new thread for this question and make sure not to limit it to a single member.
marcick Well-Known Member Licensed User Longtime User Nov 12, 2017 #96 I was reading in poste 72 - I added the AddMarker3 function, which allows to specify an origin and an anchor position for the marker icon But I understand the method has then been removed for some reasons. So ... this is still a wish ....
I was reading in poste 72 - I added the AddMarker3 function, which allows to specify an origin and an anchor position for the marker icon But I understand the method has then been removed for some reasons. So ... this is still a wish ....
marcick Well-Known Member Licensed User Longtime User Nov 28, 2017 #97 Not exactely, as far as I know. But you can check if a clicked point is inside a polygon, then do what you want. https://www.b4x.com/android/forum/threads/point-inside-a-polygon-ray-casting-algorithm.64985/
Not exactely, as far as I know. But you can check if a clicked point is inside a polygon, then do what you want. https://www.b4x.com/android/forum/threads/point-inside-a-polygon-ray-casting-algorithm.64985/
klaus Expert Licensed User Longtime User Nov 28, 2017 #98 magi6162 said: there is an event like "clickPolygon" to select a polygon? Can the selected polygon change it (move nodes, etc ..)? Click to expand... Yes. You have the PolygonClick event when the user clicks on a polygon. Then you can set it editable and / or draggable with the JavaObjects library. Same for polyline and circle. Code: Private Sub GMap_PolygonClick (SelectedPolygon As MapPolygon) Private joMapPolygon = SelectedPolygon As JavaObject joMapPolygon.RunMethod("setEditable", Array As Object(True)) joMapPolygon.RunMethod("setDraggable", Array As Object(True)) You can also add a MouseMove event, look HERE. Last edited: Nov 28, 2017
magi6162 said: there is an event like "clickPolygon" to select a polygon? Can the selected polygon change it (move nodes, etc ..)? Click to expand... Yes. You have the PolygonClick event when the user clicks on a polygon. Then you can set it editable and / or draggable with the JavaObjects library. Same for polyline and circle. Code: Private Sub GMap_PolygonClick (SelectedPolygon As MapPolygon) Private joMapPolygon = SelectedPolygon As JavaObject joMapPolygon.RunMethod("setEditable", Array As Object(True)) joMapPolygon.RunMethod("setDraggable", Array As Object(True)) You can also add a MouseMove event, look HERE.
ivanomonti Expert Licensed User Longtime User Apr 10, 2018 #100 error Code: Waiting for debugger to connect... Program started. Errore nella linea: 188 (Main) java.lang.NullPointerException at anywheresoftware.b4j.objects.GoogleMapWrapper.setMapType(GoogleMapWrapper.java:646) at b4j.example.main._listview1_selectedindexchanged(main.java:1511) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:613) at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:228) at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90) at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:93) at anywheresoftware.b4a.BA$1.run(BA.java:215) at com.sun.javafx.application.PlatformImpl.lambda$null$174(PlatformImpl.java:295) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$175(PlatformImpl.java:294) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.lambda$null$149(WinApplication.java:191) at java.lang.Thread.run(Thread.java:745) Code: googlemap.MapType = googlemap.MAP_TYPE_SATELLITE Dim cp As CameraPosition cp.Initialize(45.622065, 9.1053143, 18) googlemap.MoveCamera(cp) Attachments 2018-04-10_100004.png 12.3 KB · Views: 1,044
error Code: Waiting for debugger to connect... Program started. Errore nella linea: 188 (Main) java.lang.NullPointerException at anywheresoftware.b4j.objects.GoogleMapWrapper.setMapType(GoogleMapWrapper.java:646) at b4j.example.main._listview1_selectedindexchanged(main.java:1511) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:613) at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:228) at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90) at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:93) at anywheresoftware.b4a.BA$1.run(BA.java:215) at com.sun.javafx.application.PlatformImpl.lambda$null$174(PlatformImpl.java:295) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$175(PlatformImpl.java:294) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.lambda$null$149(WinApplication.java:191) at java.lang.Thread.run(Thread.java:745) Code: googlemap.MapType = googlemap.MAP_TYPE_SATELLITE Dim cp As CameraPosition cp.Initialize(45.622065, 9.1053143, 18) googlemap.MoveCamera(cp)