Hi! In my app every coordinate adds a marker (mpin.png) in the map. Below is a function to search a particular name, retrieve the coordinates, and change the marker (mpin2.png).
The way I change the marker is to clear the map first and add everything. This may slow down the app if the markers reach 1,000 coordinates. I appreciate any input. Thanks.
The way I change the marker is to clear the map first and add everything. This may slow down the app if the markers reach 1,000 coordinates. I appreciate any input. Thanks.
Function to search:
Private Sub SearchDialog2 'ON Panel3
ASFloatingActionButton1.CloseMenu
dialog.Initialize(Panel3)
'----------------------------------
Dim Cursor1 As Cursor
Cursor1 = SQL.ExecQuery("SELECT id,areaname,date,time,loc,result,controlno,bdate,gender,mobile,remarks FROM survey")
Log("Size " & Cursor1.RowCount)
If Cursor1.RowCount < 1 Then
Log("Empty records")
Else
Dim v1,v2,MyCoor() As String
nameSearchL.Clear
coordL.Clear
For i = 0 To Cursor1.RowCount - 1
Cursor1.Position = i
Log(Cursor1.GetString("loc") & " " & Cursor1.GetString("areaname"))
v1 = Cursor1.GetString("areaname")
v2 = Cursor1.GetString("loc")
nameSearchL.Add(v1)
coordL.Add(v2)
Next
Cursor1.Close
End If
'----------------------------------
SearchTemplate.Initialize
SearchTemplate.SetItems(nameSearchL)
'SearchTemplate.PrefixOnly = True
SearchTemplate.ItemHightlightColor = 1
dialog.Title = "Search Member"
SearchTemplate.Resize(90%x, 80%y) '
Wait For (dialog.ShowTemplate(SearchTemplate, "", "", "CANCEL")) Complete (Result As Int)
If Result = xui.DialogResponse_Positive Then
Log(SearchTemplate.SelectedItem & " < ")
For i = 0 To nameSearchL.Size-1
If nameSearchL.Get(i) = SearchTemplate.SelectedItem.Trim Then
Log(coordL.Get(i))
MyCoor = Regex.Split(",",coordL.Get(i))
Dim cp As CameraPosition
cp.Initialize(MyCoor(0),MyCoor(1), 15)
btnshowcoordinates_Click
gmap.Clear
Dim Pt1 As LatLng
Dim m1 As Marker
For i = 0 To coordLatList.Size-1
Log(coordLatList.Get(i) &"," & coordLonList.Get(i))
Pt1.Initialize(coordLatList.Get(i),coordLonList.Get(i))
Log(Pt1.Latitude & " " & Pt1.Longitude)
If Pt1.Latitude = MyCoor(0).trim And Pt1.Longitude = MyCoor(1).trim Then
m1 = gmap.AddMarker3(MyCoor(0), MyCoor(1),"No. of voters: " & countVotersL.Get(i) , SetBitmapDensity(LoadBitmap(File.DirAssets, "mpin2.png")))
m1.Snippet = MyCoor(0) & " " & MyCoor(1)
Log("m1 " & m1.Snippet)
Else
m1 = gmap.AddMarker3(Pt1.Latitude, Pt1.Longitude,"No. of voters: " & countVotersL.Get(i) , SetBitmapDensity(LoadBitmap(File.DirAssets, "mpin.png")))
m1.Snippet = Pt1.Latitude & " " & Pt1.Longitude
End If
Next
Dim latlon As LatLng
latlon.Initialize(MyCoor(0),MyCoor(1))
radar.Initialize("",gmap,latlon)
radar.withOuterCircleStrokeColor(Colors.ARGB(255,30,144,255))
radar.withDistance(1)
radar.startRadarAnimation
gmap.AnimateCamera(cp)
End If
Next
else if Result = xui.DialogResponse_Cancel Then
End If
End Sub