Overlying polygon on Google map

Hi All,

I have stored polygon coordinates in Anvil datatables but when I retrieve them from the tables to draw the polygon on google map I can’t get the polygon to show on the map and I tried storing the latlng both as text and object.

Below is the code;

  PolyRec = app_tables.polygon.get(PolyName=ShapeName)

   LatLng =  [r['LatLng'] for r in app_tables.polylatlng.search(PolygonID=PolyRec['ID'])]

   self.map.center =  r['LatLng']      

   self.map.zoom = 6

   p = GoogleMap.Polygon(

   path=[LatLng],

   stroke_color='blue',

   stroke_weight=3)

Can anyone help please?

Thanks
Sid

Is path supposed to be a list of a list?
Does it work if you hard code the LatLng?

from the documentation it looks like you need a list of GoogleMap.LatLng objects…

    path=[
      GoogleMap.LatLng(52.215, 0.14),
      GoogleMap.LatLng(52.195, 0.12),
      GoogleMap.LatLng(52.21, 0.10),
    ],

How can you store GoogleMap.LatLng in Anvil datatables and retrieve them. I tried storing them as string but couldn’t typecast them back to GoogleMap.LatLng.

Thank you in advance for your help.

You could store the two values separately as floats
or you could store the two values as a list in a simple object in the datatable
and then turn it into a GoogleMap.LatLng on the client side.

Yes, that worked. Many thanks