ElemeFE / react-amap

基于 React 封装的高德地图组件。AMap Component Based On React.
https://elemefe.github.io/react-amap/articles/start
MIT License
1.04k stars 151 forks source link

useCluster无法使用 #24

Closed fufjvnvnf closed 7 years ago

fufjvnvnf commented 7 years ago

react-amap version

0.2.7

OS/Browers version

macOS/Safari

Reproduction Link

Steps to reproduce

class AMapboxViz extends React.Component {

  constructor(props){
    super(props);

    const markers = this.props.locations;
    this.state={
      useCluster: true,
    };

    this.state = {
      markers
    };
  }

  render(){
    return (
      <Map
        amapkey={'ba035e10b09acfc492d168adfd1b97cb'}
        center={{longitude: 110, latitude: 40}}
        zoom={5}
      >
        <Markers
          markers={this.state.markers}
          useCluster={this.state.useCluster}
        />
      </Map>
    );
  }
}
function amapbox(slice, json){
  const div = d3.select(slice.selector);
  div.selectAll('*').remove();
  ReactDOM.render(
    <AMapboxViz
      {...json.data}
    />,
    div.node(),
  );
}

What is Expected?

显示的地图的marker会cluster成圆圈。

What is actually happening?

仅显示了markers,并没有cluster起来。

fufjvnvnf commented 7 years ago

好吧 是由于constructor内两个紧接着的this.state={},第二个把第一个overwrite了。