I'm trying to use the method distanceFrom (and also getBearing) with the GoogleMaps library.
http://rterp.github.io/GMapsFX/apidocs/com/lynden/gmapsfx/javascript/object/LatLong.html
My app using OSMDroid needs to find the distance and bearing of the nearest Geopoint to each of the
objects it deals with.
It seemed sensible to precompute this on the server to be included in the download that the app requests every minute.
This code:
generates this error on - NearPoint.Initialize(NearPointLat, NearPointLon)
If I remove the NearPoint and NearPoint.Initialize and change Here.InitializeNewInstance to
Here.InitializeNewInstance("com.lynden.gmapsfx.javascript.object.LatLong", Array (NearPointLat, NearPointLon))
I get this error on the Here.InitializeNewInstance
http://rterp.github.io/GMapsFX/apidocs/com/lynden/gmapsfx/javascript/object/LatLong.html
My app using OSMDroid needs to find the distance and bearing of the nearest Geopoint to each of the
objects it deals with.
It seemed sensible to precompute this on the server to be included in the download that the app requests every minute.
This code:
B4X:
Dim NearPoint As LatLng
Dim NearPointLat As Double = 52.750137
Dim NearPointLon As Double = 1.072345
Dim FarPoint As LatLng
Dim FarPointLat As Double = 52.707931
Dim FarPointLon As Double = 1.550293
Dim Here As JavaObject
NearPoint.Initialize(NearPointLat, NearPointLon)
Here.InitializeNewInstance("com.lynden.gmapsfx.javascript.object.LatLong", Array (NearPoint.Latitude, NearPoint.Longitude))
FarPoint.Initialize(FarPointLat, FarPointLon)
Log(Here.RunMethod("distanceFrom", Array (FarPoint)))
generates this error on - NearPoint.Initialize(NearPointLat, NearPointLon)
Waiting for debugger to connect...
Program started.
Error occurred on line: 24 (Main)
java.lang.NullPointerException
at com.lynden.gmapsfx.javascript.JavascriptRuntime.execute(JavascriptRuntime.java:63)
at com.lynden.gmapsfx.javascript.JavascriptObject.<init>(JavascriptObject.java:76)
at com.lynden.gmapsfx.javascript.object.LatLong.<init>(LatLong.java:36)
at anywheresoftware.b4j.objects.GoogleMapWrapper$LatLngWrapper.Initialize(GoogleMapWrapper.java:271)
at b4j.example.main._appstart(main.java:106)
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:229)
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.raiseEvent(BA.java:84)
at b4j.example.main.start(main.java:36)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
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)
If I remove the NearPoint and NearPoint.Initialize and change Here.InitializeNewInstance to
Here.InitializeNewInstance("com.lynden.gmapsfx.javascript.object.LatLong", Array (NearPointLat, NearPointLon))
I get this error on the Here.InitializeNewInstance
I'd be grateful for some pointer as to where I'm going wrong here.Waiting for debugger to connect...
Program started.
Error occurred on line: 26 (Main)
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at anywheresoftware.b4j.object.JavaObject.InitializeNewInstance(JavaObject.java:90)
at b4j.example.main._appstart(main.java:106)
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:229)
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.raiseEvent(BA.java:84)
at b4j.example.main.start(main.java:36)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
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)
Caused by: java.lang.NullPointerException
at com.lynden.gmapsfx.javascript.JavascriptRuntime.execute(JavascriptRuntime.java:63)
at com.lynden.gmapsfx.javascript.JavascriptObject.<init>(JavascriptObject.java:76)
at com.lynden.gmapsfx.javascript.object.LatLong.<init>(LatLong.java:36)
... 30 more