B4J Question [SOLVED] Can't find variable: google

makis_best

Well-Known Member
Licensed User
Longtime User
I have made a simple google map application show some markers using @Erel example.
Until today the application was working fine.

Now I get the error
Waiting for debugger to connect...
Program started.
Error occurred on line: 163 (Main)
netscape.javascript.JSException: ReferenceError: Can't find variable: google
at com.sun.webkit.dom.JSObject.fwkMakeException(JSObject.java:156)
at com.sun.webkit.WebPage.twkExecuteScript(Native Method)
at com.sun.webkit.WebPage.executeScript(WebPage.java:1519)
at javafx.scene.web.WebEngine.executeScript(WebEngine.java:1005)
at com.lynden.gmapsfx.javascript.JavaFxWebEngine.executeScript(JavaFxWebEngine.java:42)
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.googlemaps.GoogleMapWrapper.AddMarker2(GoogleMapWrapper.java:342)
at anywheresoftware.b4j.googlemaps.GoogleMapWrapper.AddMarker(GoogleMapWrapper.java:329)
at b4j.google.map.main._combobox1_selectedindexchanged(main.java:287)
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:632)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
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:91)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA$1.run(BA.java:216)
at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(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$4(WinApplication.java:186)
at java.lang.Thread.run(Thread.java:748)

I didn't change anything on my code but I get that error.
Why?

jFX 7.50
jGoogleMaps 1.81
 

Harris

Expert
Licensed User
Longtime User
Supply the code from Main...
Thanks
 
Upvote 0

makis_best

Well-Known Member
Licensed User
Longtime User
Supply the code from Main...
Thanks
B4X:
    MainForm = Form1
    MainForm.Show
    MainForm.RootPane.LoadLayout("1") 'Load the layout file.
    DatePicker1.DateFormat = "dd/MM/yyyy"
    MarkerList.Initialize
    Dim url As String
    url = "jdbc:sqlserver://xxxxxxxxx;integratedSecurity=false;databaseName=xxxxxx;"
    sql1.Initialize2("com.microsoft.sqlserver.jdbc.SQLServerDriver",url, "xxx", "xxxxxxx")
    Dim rs As ResultSet = sql1.ExecQuery("SELECT Code, Name FROM SFIS WHERE fCommercialUnitCode = '001' ORDER BY Code")
    ComboBox1.Items.Add("Όλοι")
    Do While rs.NextRow
        ComboBox1.Items.Add(rs.GetString("Code") & " - " & rs.GetString("Name"))
    Loop
    rs.Close
    ComboBox1.SelectedIndex = 0

    options.StreetViewControl = False
    gmap.Initialize2("gmap", options, "xxxxxxxxxxxxxxxxxxxxx")
    Pane1.AddNode(gmap.AsPane, 0, 0, Pane1.Width, Pane1.Height)
    MarkerInfos.Initialize
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
Error occurred on line: 163 (Main) - don't see this with what you supplied...
 
Upvote 0

makis_best

Well-Known Member
Licensed User
Longtime User
Error occurred on line: 163 (Main) - don't see this with what you supplied...

Sorry wrong copy paste
B4X:
Sub ComboBox1_SelectedIndexChanged(Index As Int, Value As Object)
    If MarkerList.Size > 0 Then
        For i = 0 To MarkerList.Size - 1
            gmap.RemoveMarker(MarkerList.Get(i))
        Next
        MarkerList.Clear
    End If
    Dim Cb As String
    Cb = ComboBox1.Value
    If Cb = "Όλοι" Then
        Cb = "%"
    Else
        Cb = Cb.SubString2(0,3).Trim
    End If
    Dim Dt1 As String = DateTime.Date(DatePicker1.DateTicks)
    Dim SqlScript As String
    SqlScript = $"SELECT * FROM GPS"$
    Dim rs As ResultSet = sql1.ExecQuery(SqlScript)
    Do While rs.NextRow
        Dim Lo, La As Double
        Lo = rs.GetDouble("Long")
        La = rs.GetDouble("Lang")
        Dim m As Marker = gmap.AddMarker(Lo, La, "Ώρα: " & rs.GetString("Time1")) ---->  Here the code stop
        AttachInfoWindow(m, "Proof: " & rs.GetString("SM"))
        MarkerList.Add(m)
    Loop
    rs.Close
End Sub
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
AddMarker( Lat, Lon, "Title") looks like you use - lon, lat as param...

Also, do you have an API key for google map?
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
Try logging results... Catch the error!

B4X:
Do While rs.NextRow
        Dim Lo, La As Double
        Lo = rs.GetDouble("Long")
        La = rs.GetDouble("Lang")
        
        
        ' Log the vars and see what you get...
        Log( "Lat: "&La& "  Long: "&Lo &"  Time1: "&rs.GetString("Time1") )
        
       Try 
           Dim m As Marker = gmap.AddMarker(Lo, La, "Ώρα: " & rs.GetString("Time1")) ---->  Here the code stop
       Catch
           Log(" Last Error: "&LastException.Message)
        End Try

        AttachInfoWindow(m, "Proof: " & rs.GetString("SM"))
        MarkerList.Add(m)
    Loop
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
"google" is google's map api's master object. if it is not found, it means the api was not downloaded successfully from google. why this has happened is hard to say, but downloading the api does not depend on having an api key. (using the api, on the other, hand, would require a valid key). if, in fact, you have changed nothing, then something has changed on the other end (or possibly on your network's end).

for example, i can make a similar error occur simply by not being online when using a google-related map app of mine, thus causing the download to fail and references to "google" throw an error. i'm not suggesting you are not online; i am just telling you what "google" means.
 

Attachments

  • google.png
    google.png
    3.6 KB · Views: 197
Upvote 0

josejad

Expert
Licensed User
Longtime User
Could it be related with this?
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
certainly one possibility (if not the actual reason). always good to have a backup plan. also doesn't hurt to know what "google not found" means. saludos, jja
 
Upvote 0

makis_best

Well-Known Member
Licensed User
Longtime User
After I wait for a day and after I clean project then
I get the same error but on different line
B4X:
infoWindow.InitializeNewInstance("com.lynden.gmapsfx.javascript.object.InfoWindow", Null)
 
Upvote 0

makis_best

Well-Known Member
Licensed User
Longtime User
I check com.lynden.gmapsfx.javascript.object and I can't see any last change or update but the problem exist
 
Upvote 0
Top