I need to create an application that allows the user to create a polygon directly in the maps component.
I didn’t find any function that does this and no tutorial.
Who can help me the solution can be both for Google Maps, When for MapBox, whichever is easier.
Sorry for the mistakes in the sentences. I’m using google translate . I hope you can understand my need.
I haven’t tried this but from the Anvil Docs this is possible
Google Maps You can display interactive Google Maps on your Anvil Form with the GoogleMap component. Drag and drop onto your Form, or create one in code with the GoogleMap constructor.
map = GoogleMap() map.center = GoogleMap.LatLng(52.2053, 0.1218)...
Searching the forum I found this post.
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(
p…
I think you need to capture the points of the polygon in LatLng objects and then use those to display the polygon.
Have you got a clone of the app to show what you have done so far?
1 Like
Hello!!
I resumed the project and managed to move forward. I was able to use the mouse to draw the map directly in Google Maps and also retrieve the drawing in a GoogleMap.Polygon object.
In order to finish my project, I need to put a label on the drawn map so that it can be identified by the user, when there are many polygons together.
In the same way as the image below.
Thanks a lot for the help. As soon as I finish the first version of the application I will share it with you.
1 Like