Reactjs 无法从RadiusChanged事件上的可编辑圆获取半径值
我是谷歌地图的新手。我无法从圆中获取半径值 我想在RadiusChanged事件中获取圆半径 index.js map.js 结果- 未定义 onRadiusChanged作为Circle类事件的基础不接受任何参数。由于在您的示例中,onRadiusChanged事件处理程序方法未与其组件实例绑定,因此更新后的radius可以如下确定:Reactjs 无法从RadiusChanged事件上的可编辑圆获取半径值,reactjs,google-maps,react-google-maps,Reactjs,Google Maps,React Google Maps,我是谷歌地图的新手。我无法从圆中获取半径值 我想在RadiusChanged事件中获取圆半径 index.js map.js 结果- 未定义 onRadiusChanged作为Circle类事件的基础不接受任何参数。由于在您的示例中,onRadiusChanged事件处理程序方法未与其组件实例绑定,因此更新后的radius可以如下确定: updateRadius() { const updatedRadius = this.getRadius(); } 这里指的是本地的 import
updateRadius() {
const updatedRadius = this.getRadius();
}
这里指的是本地的
import React, { Component } from "react";
import {
withScriptjs,
withGoogleMap,
GoogleMap,
Marker,
Circle
} from "react-google-maps";
class MyMapComponent extends Component {
constructor(props) {
super(props);
this.state = {
radius: 50
}
}
updateRadius(e) {
console.log(e);
}
render() {
return (
<GoogleMap
defaultZoom={this.props.zoom}
defaultCenter={this.props.center}
>
<Marker google={this.props.google}
name={'Dolores park'}
draggable={true}
onDragEnd={this.onMarkerDragEnd}
position={this.props.center}
/>
<Circle
center={this.props.center}
options={{
strokeColor: "#FF0000",
strokeOpacity: 0.8,
strokeWeight: 1,
fillColor: "#FF0000",
fillOpacity: 0.35,
clickable: false,
draggable: false,
editable: true,
visible: true,
radius: this.state.radius, //Calculation in Meter
zIndex: 1
}}
onRadiusChanged={this.updateRadius}
/>
</GoogleMap>
);
}
}
export default withScriptjs(withGoogleMap(MyMapComponent));
updateRadius() {
const updatedRadius = this.getRadius();
}