B4J Question [SOLVED] How to save jgooglemaps Polygon to file or Database?

Magma

Expert
Licensed User
Longtime User
If i use jsonparser to string....

Tried but getting this error:


B4X:
Sub convertpol_Action
Log(lst)
    pol=gmap.AddPolygon(lst,1,fx.Colors.Red,fx.Colors.Red,0.5)
end sub

lst is a list object...

I am generating json to string or pretty string...

B4X:
    Dim jp As JSONGenerator
    Dim sp As String
    'For k=0 To lst.Size-1      'here tried if was problem of commas... but was not...
    '    Dim sp As String=lst.Get(k)
    '    sp=sp.Replace(",",".")
    '    lst.Set(k,sp)
    'Next
    jp.Initialize2(lst)
    sp=jp.ToPrettyString(3)
    sql1.ExecNonQuery("UPDATE polygggons SET polytext='"&TextField1.Text.Trim&"', poly1='" & sp & "' WHERE myid= '" & ListView1.Items.Get(ListView1.SelectedIndex) &"';")

I am parsing with json the list...

B4X:
        Dim jp As JSONParser
        jp.Initialize(polys(Index))
        lst.Clear
        lst = jp.NextArray

but getting the error i said...

Is it possible with json or only with way you are saying ?
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
When i am doing this code (add positions to list) :
B4X:
Sub gmap_Click (Point As LatLng)
    mark(pnt)=gmap.AddMarker(Point.Latitude,Point.Longitude,"Point-"&(pnt+1))
    Dim newposition As LatLng
    newposition.Initialize(Point.Latitude,Point.Longitude)
    lst.Add(newposition)
    pnt=pnt+1
End Sub


then convertpol_action sub working / but when loading lst with json not convertpol_action sub ( pol=gmap.AddPolygon(lst,1,fx.Colors.Red,fx.Colors.Red,0.5) ) not works...
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
Just found the reason and the solution.

Is because the newposition is LatLng and when reading that list from db reading as string :-(

So the best way is to save 2 arrays that will be string with no problem (of lat and lng) and turn them in positions (latlng object)..
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…