#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 400
#End Region
#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;
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private Pane1 As Pane
Private gmap As GoogleMap
Private btnResetMap As Button
Private btnJumpToEiffel As Button
Private MarkerInfos As Map
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.Show
MainForm.RootPane.LoadLayout("1") 'Load the layout file.
Dim options As MapOptions
options.StreetViewControl = False
' gmap.Initialize("gmap", options) 'You should call Initialize2 and set the API key!
gmap.Initialize2("gmap",options,"AIzaSyAEZ2xfst5HXEiikHJeyFkRUBJ7KhM_1Hc")
Pane1.AddNode(gmap.AsPane, 0, 0, Pane1.Width, Pane1.Height)
MarkerInfos.Initialize
End Sub
Sub gmap_Ready
btnResetMap.Enabled = True
btnJumpToEiffel.Enabled = True
For i = 1 To 10
Dim m As Marker = gmap.AddMarker(10 * i, 10 * i, "Marker #" & i)
AttachInfoWindow(m, "Some text " & i)
Next
End Sub
Sub gmap_Click (Point As LatLng)
Log($"$1.3{Point.Latitude} / $1.3{Point.Longitude}"$)
End Sub
Sub gmap_MarkerClick (SelectedMarker As Marker)
ShowInfoWindow(SelectedMarker, gmap)
End Sub
Private Sub ShowInfoWindow (Marker As Marker, Map As GoogleMap)
If MarkerInfos.ContainsKey(Marker) Then
Dim info As JavaObject = MarkerInfos.Get(Marker)
Dim jMap As JavaObject = Map
jMap = jMap.GetField("map")
info.RunMethod("open", Array (jMap, Marker))
End If
End Sub
Private Sub AttachInfoWindow (Marker As Marker, Text As String)
Dim infoWindow As JavaObject
infoWindow.InitializeNewInstance("com.lynden.gmapsfx.javascript.object.InfoWindow", Null)
infoWindow.RunMethod("setContent", Array (Text))
MarkerInfos.Put(Marker, infoWindow)
End Sub
Sub btnResetMap_Action
Dim cp As CameraPosition
cp.Initialize(0, 0, 1)
gmap.MoveCamera(cp)
End Sub
Sub Pane1_Resize (Width As Double, Height As Double)
gmap.AsPane.SetSize(Width, Height)
End Sub
Sub btnJumpToEiffel_Action
gmap.MapType = gmap.MAP_TYPE_SATELLITE
Dim cp As CameraPosition
cp.Initialize(48.858260, 2.29517, 18)
gmap.MoveCamera(cp)
End Sub