Reactjs Can';无法从react google maps事件获取新坐标
我想从谷歌地图的多边形组件的onDragEnd中获取新坐标Reactjs Can';无法从react google maps事件获取新坐标,reactjs,google-maps-api-3,geometry,polygon,react-google-maps,Reactjs,Google Maps Api 3,Geometry,Polygon,React Google Maps,我想从谷歌地图的多边形组件的onDragEnd中获取新坐标 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
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>
);
}
}
类CustomMap扩展了React.Component{
handlePolygonDrag=(e)=>{
console.log(e);//事件没有多边形对象
console.log(this);//这指的是CustomMap组件,而不是多边形
}
render(){
返回(
({
lat:索引[0],
液化天然气:指数[1],
}))(currentFence.shape.loc.coordinates)}
键={1}
options={this.state.polygon.options}
onDragEnd={this.handlePolygonDrag}
/>
);
}
}
但拖动后无法获取多边形的任何引用。有关实际和预期结果,请参见代码注释