1

I want to get new coordinates from onDragEnd of Polygon component of react-google-map

class CustomMap extends React.Component {
    handlePolygonDrag = (e) => {
        console.log(e); // event does not have a polygon object
        console.log(this); // this refers to the CustomMap component, not the Polygon
    }

    render() {
        return (
            <Div>
                <Map>
                    <Polygon
                        path={R.map((index) => ({
                            lat: index[0],
                            lng: index[1],
                        }))(currentFence.shape.loc.coordinates)}
                        key={1}
                        options={this.state.polygon.options}
                        onDragEnd={this.handlePolygonDrag}
                    />
                </Map>
            </Div>
        );
    }
}

But cannot get any reference of the Polygon after being dragged. Please see the code comments for actual & expected outcomes.

0 Answers0