Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用Boundary行政区域组件时,出现了前一个区域的边界线没有清除问题,导致显示错乱。 #89

Closed
FishLuo1992 opened this issue Feb 11, 2019 · 5 comments
Labels
type: bug Something isn't working

Comments

@FishLuo1992
Copy link

需求:动态选择省下面的市,Boundary的name动态改变。问题:当选中第二个开始,前面的行政区域的覆盖物和边界线没有清除。

有方法能每次更新都清楚前面的Boundary视图层吗?

@JserWang
Copy link
Owner

需求:动态选择省下面的市,Boundary的name动态改变。问题:当选中第二个开始,前面的行政区域的覆盖物和边界线没有清除。

有方法能每次更新都清楚前面的Boundary视图层吗?

@FishLuo1992 嗨,能否在 https://codesandbox.io 中给我一个demo?选择第二个后,第一个没有清除?另外,你当前使用的rc-bmap的版本是?

也许你给我部分代码片段,有助于帮助我来解决你遇到的问题。

@FishLuo1992
Copy link
Author

`import React,{ Component } from 'react';
import { Map,Boundary } from 'rc-bmap';
import Linkage from './components/linkageForm'
import styles from './common.less';
export default class ChartsTest extends Component{
constructor(props){
super(props)
this.state ={
siteName:'广东省',
selectCity:'',
}
}

// 选择城市
handleCityChange=(value)=>{
const siteName = 广东省${value}
this.setState({siteName,selectCity:value})
}

renderSearchForm =()=>{
return (


<Linkage
handleCityChange={(value) =>{this.handleCityChange(value)}}
/>

)
}

renderBoundary = (siteName)=>{
return (

)
}

render() {
const { siteName } = this.state
return (



{this.renderSearchForm()}
{this.renderBoundary(siteName)}


);
}
}`

Linkage是我定义省下面的市下拉选择和搜索的Form表单组件,选中后需要更改行政区域。 rc-bmap是"rc-bmap": "^1.0.1"。

@JserWang
Copy link
Owner

感谢提供,
目前你可以通过React的渲染机制,为Boundary给一个key来进行强制更新,这种写法会在rc-bmap中的下个版本进行优化。

renderBoundary = (siteName) => {
 return (
   <Boundary 
      key={`Boundary_${siteName}`}
      name={siteName}
      ...
   />
 )
}

@JserWang JserWang added the type: bug Something isn't working label Feb 11, 2019
@JserWang
Copy link
Owner

现在你可以升级至1.0.2体验。

@FishLuo1992
Copy link
Author

感谢大佬。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants