I am trying to add a feature that allows the user to draw a polygon on the map - and then click on the polygon to trigger an action.
I am able to do both things separately, but not together. In other words, on one side I have a list of shapes, and each one contains a "ShapeEvent" that works properly, and on the other side I have a drawing tool that allows me to draw the polygon I want - but i am unable to add the "ShapeEvent" to the drawn polygon like the preset polygon shapes.
Is this a known issue? is there a work-around?
One solution I tried (unsuccessfully) was to have a list of "Shapes\Polygon" that starts off empty. Then besides the list, i have a "Drawing_Tools" block with a "DrawPolygon" underneath it.
I added a client action that runs in the "OnDrawingChange" event of the drawing block - and what the client action does is duplicates the drawn shape into the "Shapes\Polygon" List (which includes the action I wish to run when the shape is right-clicked). This works perfectly, all besides the fact i now have 2 shapes (one drawn, and the other in the shapes list). I tried looking for a JS that deletes the drawn shape after creating the "Shapes\Polygon", but could not do this successfully.
Anyone have any new ideas or insights?
Ended up finding a solution myself playing around a bit more with Javascript.
var zoom = MapAPI.MapManager.GetMapById($parameters.mapId)._provider.zoom;var lat = MapAPI.MapManager.GetMapById($parameters.mapId)._provider.center.lat();var lng = MapAPI.MapManager.GetMapById($parameters.mapId)._provider.center.lng();OutSystems.Maps.MapAPI.ShapeManager.RemoveShape($parameters.PolygonId);OutSystems.Maps.MapAPI.MapManager.ChangeProperty($parameters.mapId, 'center', lat + ',' + lng);OutSystems.Maps.MapAPI.MapManager.ChangeProperty($parameters.mapId, 'zoom', zoom);
Thanks anyway!
Hello @Noam Shimoni
If you share an oml with that use case implement we can try to help.
Cheers,GM