<div style={{ width: "100%", height: "500px", padding: "10px" }}>
<Map
plugins={this.mapPlugins}
center={this.mapCenter}
amapkey=""
events={this.events}
>
<MouseTool events={this.toolEvents} />
{points && points.length >= 3 && (
<Polygon path={points} style={mapStyle}>
<PolyEditor active={false} events={this.editorEvents}/>
</Polygon>
)}
</Map>
</div>
这里可以直接放入Polygon组件
然后
this.toolEvents = {
created: tool => {
console.log(tool);
self.tool = tool;
self.tool.polygon();
},
draw({ obj }) {
self.drawWhat(obj);
}
};
然后在constructor里面的toolEvents里,created后,直接调用self.tool.polygon();
就能开始绘多边形了