The draw toolbar in Geolocation child table

The draw toolbar of Geolocation is not displaying in childtable, and I’m unable to select the location correctly in the Geolocation field within the child table. how can i add it

i do ike this in form but not work

contratsTable.grid.grid_rows.forEach(function(row) {
        // Access the map field 'map_data' in each row
        var mapField = row.map_data;
        if (mapField && mapField.map) {
            let map = mapField.map;
            // Add Leaflet.draw plugin to the map
            var drawnItems = new L.FeatureGroup();
            map.addLayer(drawnItems);
            var drawControl = new L.Control.Draw({
                edit: {
                    featureGroup: drawnItems
                },
                draw: {
                    polygon: true,
                    polyline: false,
                    rectangle: false,
                    circle: false,
                    circlemarker: false
                }
            });
            map.addControl(drawControl);

            // Event handler for when a polygon is created
            map.on('draw:created', function(event) {
                var layer = event.layer;
                drawnItems.addLayer(layer);
            });
        }
    });

the first time that i work with geolocation any help,

1 Like

any help please

1 Like

I found the solution

form_render: function(frm, cdt, cdn) {    
        let childTableData = frm.get_field('child_table_field_name').grid.grid_rows;
        childTableData.forEach(childRow => {
            let map = childRow.get_field('map_data').map;
            // Ensure map is not undefined
            if (map) {
                // Add Leaflet.draw plugin to the map
                var drawnItems = new L.FeatureGroup();
                map.addLayer(drawnItems);
                var drawControl = new L.Control.Draw({
                    edit: {
                        featureGroup: drawnItems
                    },
                    draw: {
                        polygon: true,
                        polyline: false,
                        rectangle: false,
                        circle: false,
                        circlemarker: false
                    }
                });
                map.addControl(drawControl);
                // Event handler for when a polygon is created
                map.on('draw:created', function(event) {
                    var layer = event.layer;
                    drawnItems.addLayer(layer);
                });
            }
        });
   }
3 Likes