B4X:
Sub Process_Globals
Dim p1 As Parse
Dim Geocoder1 As Geocoder
Dim flgLoggedIn As Boolean=False
Dim flgLogInShown As Boolean=False
Dim vstrUserName As String =""
Dim MarkerList As List
Dim gmap As GoogleMap
Dim gme1 As GoogleMapsExtras
Dim vflgFromSourceEdit As Boolean = False
Dim flgWaitingForGPS As Boolean = False
End Sub
Sub Globals
Dim MapFragment1 As MapFragment
Private Panel1 As Panel
Dim LatLngBoundsBuilder1 As LatLngBoundsBuilder
Dim MarkerBounds As LatLngBounds
Private Label1 As Label
Dim strf As StringFunctions
Dim MarkerOldPos As LatLng
Private btnAddRecord As Button
Private btnGetData As Button
Private btnSendData As Button
Private pbTransferProgress As ProgressBar
Private lblCntInfo As Label
Private btnShowAll As Button
Private btnRefresh As Button
End Sub
Sub LoadSourceMarkers
Dim Row As Int
Dim Cursor1 As Cursor
Dim RowCnt, Row As Int
Dim vNeighBourHoodCnt As Int = "0" & General.SQL1.ExecQuerySingleResult("Select count(distinct Neighbourhood ) from Sources ;").Trim
Dim vstrSQL001 As String= "SELECT Active, Changed, Synchronized, SourceID, Latitude, Longitude, SourceName, SourceType, City, District, Neighbourhood, MainStreet, Street, Address1, Address2, DoorNumber, PhoneNumber, TaxNumber, SurveyStatus "
Dim vIX001 As Int
For vIX001=1 To General.ADDITIONALFIELDCOUNT
vstrSQL001 = vstrSQL001 & ", I"& NumberFormat(vIX001-1,2,0)
Next
For vIX001=1 To General.ADDITIONALFIELDCOUNT
vstrSQL001 = vstrSQL001 & ", V"& NumberFormat(vIX001-1,2,0)
Next
vstrSQL001 = vstrSQL001 & " FROM Sources "
Cursor1 = General.SQL1.ExecQuery(vstrSQL001)
LatLngBoundsBuilder1.Initialize
If Cursor1.RowCount > 0 Then 'check if entries exist
RowCnt = Cursor1.RowCount 'set the row count variable
lblCntInfo.Text = NumberFormat( vNeighBourHoodCnt,1,0) & " mahalle, " & NumberFormat( RowCnt,1,0) & " adet nokta mevcut."
lblCntInfo.BringToFront
pbTransferProgress.SendToBack
If MarkerList.IsInitialized Then
If MarkerList.Size>0 Then
Dim ii As Int
For ii=0 To MarkerList.Size-1
Dim m0001 As Marker= MarkerList.Get(ii)
m0001.Remove
m0001=Null
Next
End If
MarkerList.Clear
End If
MarkerList.Initialize 'initialize the ID list
For Row = 0 To RowCnt - 1
Cursor1.Position = Row 'set the Cursor to each row
Dim Source0 As SourceInfo = General.GetSourceFromCursor( Cursor1 )
Dim m01 As Marker
Dim vfltLat As Float= Source0.Latitude
Dim vfltLon As Float= Source0.Longitude
Dim vColor01 As Float = gmap.HUE_BLUE
If (Source0.Changed=1) Then vColor01 = gmap.HUE_GREEN
If (Source0.Active=0) Then vColor01 = gmap.HUE_RED
m01 = gmap.AddMarker2( vfltLat, vfltLon, Source0.SourceID, vColor01)
m01.Draggable = True
m01.Title = Source0.SourceName
m01.Snippet = Source0.SourceID
m01.Visible = True
m01.InfoWindowShown = True
LatLngBoundsBuilder1.Include(m01.Position)
MarkerList.Add(m01) 'add the markers to the marker list
Next
End If
Cursor1.Close
End Sub
Sub OnMapLoadedCallback1_MapLoaded
Log("OnMapLoadedCallback1_MapLoaded")
'flgMapLoaded=True
If Not( vflgFromSourceEdit) Then
LoadSourceMarkers
Dim vstrSQL001 As String= "SELECT IFNULL(count(*),'0') FROM Sources ;"
Dim vRes001 As String = General.SQL1.ExecQuerySingleResult(vstrSQL001)
If (vRes001<>"0") Then
MarkerBounds = LatLngBoundsBuilder1.Build
gme1.AnimateToBounds(gmap, MarkerBounds,30)
End If
'Dim ix0091 As Int =0
' For ix0091 = 1 To MarkerList.Size
' Dim m001 As Marker = MarkerList.Get(ix0091-1)
' m001.InfoWindowShown = True
' Next
End If
vflgFromSourceEdit = False
End Sub
Sub MapFragment1_MarkerClick (SelectedMarker As Marker) As Boolean 'Return True to consume the click
Return False
End Sub
Sub MapFragment1_Ready
Log("map ready")
gmap = MapFragment1.GetMap
If gmap.IsInitialized Then
Dim OnMapLoadedCallback1 As OnMapLoadedCallback
OnMapLoadedCallback1.Initialize("OnMapLoadedCallback1")
gme1.SetOnMapLoadedCallback(gmap, OnMapLoadedCallback1)
Dim OnMyLocationButtonClickListener1 As OnMyLocationButtonClickListener
OnMyLocationButtonClickListener1.Initialize("OnMyLocationButtonClickListener1")
gme1.SetOnMyLocationButtonClickListener(gmap, OnMyLocationButtonClickListener1)
Dim OnInfoWindowClickListener1 As OnInfoWindowClickListener
OnInfoWindowClickListener1.Initialize("OnInfoWindowClickListener1")
gme1.SetOnInfoWindowClickListener(gmap, OnInfoWindowClickListener1)
Dim OnMarkerDragListener1 As OnMarkerDragListener
OnMarkerDragListener1.Initialize("OnMarkerDragListener1")
gme1.SetOnMarkerDragListener(gmap,OnMarkerDragListener1)
Dim CameraPosition1 As CameraPosition
CameraPosition1.Initialize(52.7523, 0.4049, 10)
gmap.AnimateCamera(CameraPosition1)
Else
Log("Error initializing GoogleMap")
ToastMessageShow("Error initializing GoogleMap", False)
End If
If gmap.IsInitialized = False Then
Log("Error initializing GoogleMap")
ToastMessageShow("Error initializing map.", True)
Else
gmap.MyLocationEnabled=True
End If
End Sub
Sub OnMapLoadedCallback1_MapLoaded
Log("OnMapLoadedCallback1_MapLoaded")
'flgMapLoaded=True
If Not( vflgFromSourceEdit) Then
LoadSourceMarkers
Dim vstrSQL001 As String= "SELECT IFNULL(count(*),'0') FROM Sources ;"
Dim vRes001 As String = General.SQL1.ExecQuerySingleResult(vstrSQL001)
If (vRes001<>"0") Then
MarkerBounds = LatLngBoundsBuilder1.Build
gme1.AnimateToBounds(gmap, MarkerBounds,30)
End If
'Dim ix0091 As Int =0
' For ix0091 = 1 To MarkerList.Size
' Dim m001 As Marker = MarkerList.Get(ix0091-1)
' m001.InfoWindowShown = True
' Next
End If
vflgFromSourceEdit = False
End Sub
I am developing since 4-5 months with B4A and it is a very nice IDE and compiler package.
I want to thank Erel once more for providing us this software.
My question is shortly in the title, but let me explain a little:
I have a Google Maps component on a panel, and dynamic markers which come from a SQLite DB.
The application has also GPS and 3G support. My need is simply showing the titles of the points in the markers, with a length of 10-20 characters, near the marker.
Marker component's InfoWindowShown property would be OK for me, but when i make it true for all markers in a loop, the result is that only the last one is showing up. I assume, when one marker shows InfoWindow, the other InfoWindows are closed. This could be enough for me if worked.
If anyone has experience on this, a guidance would be very great.
I read some text about overlay methods, but i am not sure about them because memory need increases rapidly and my program also crashed by bmp format marker icon trials.
Is there some alternatives you would suggest?
Thanks and regards,
Serdar
Last edited: