Hi all,
I have had some excellent help for the JSON, but there is one last problem. Everything works fine with the JSON but the Mapview does not add the icons.
Here is the code:
I have tried using the default marker using Null, but it is to no avail. In case there is a problem embeded deeper in the code then I have also attached the rest.
Thanks for all the help so far,
Neil
I have had some excellent help for the JSON, but there is one last problem. Everything works fine with the JSON but the Mapview does not add the icons.
Here is the code:
B4X:
Sub JSONResponse_StreamFinish (Success As Boolean, TaskId As Int)
MapView1.RemoveOverlay(MarkersOverlay1)
Dim Icon As BitmapDrawable
Icon.Initialize(LoadBitmap(File.DirAssets, "markerting.png"))
Dim a As Int
a = 0
Dim List1 As List
Dim JSON As JSONParser
JSON.Initialize(File.ReadString(File.DirInternalCache, jsonfile &".json"))
List1.Initialize
List1 = JSON.NextArray
Dim m As Map 'helper map for navigating
m = List1.Get(0)
Dim loc As Map
Dim Markers As List
Markers.Initialize
loc = m.Get("location")
For i = 0 To m.Size - 1
Dim Marker1 As Marker
Marker1.Initialize("", "", loc.Get ("longitude"), loc.Get ("latitude"), Icon)
Markers.Add(Marker1)
a = a + 1
Next
MarkersOverlay1.AddMarkers(Markers)
MapView1.AddOverlay(MarkersOverlay1)
If a > 0 Then
Else If a = 0 Then
ToastMessageShow("Lucky you! There is no crime in your area!", True)
Else
End If
HttpTimer.Enabled = False
jsonfile = Rnd(0, 9999999)
End Sub
I have tried using the default marker using Null, but it is to no avail. In case there is a problem embeded deeper in the code then I have also attached the rest.
Thanks for all the help so far,
Neil