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

这个坑真是难破,有解决的吗 #77

Closed
zyh2123606 opened this issue Dec 13, 2018 · 1 comment
Closed

这个坑真是难破,有解决的吗 #77

zyh2123606 opened this issue Dec 13, 2018 · 1 comment

Comments

@zyh2123606
Copy link

在Map/index.js中

 componentDidMount() {
    const { ak } = this.props;
    if (ak) {
      this.getMapScript().then(this.init);
    } else if (global.BMap) {
      this.init(global.BMap);
    } else {
      console.warn('BMap is undefined');
    }
  }

觉得应该修改一下顺序

componentDidMount() {
  const { ak } = this.props;
  if (global.BMap) {
    this.init(global.BMap);
  }
  else if (ak) {
    this.getMapScript().then(this.init);
  }
  else {
    console.warn('BMap is undefined');
  }
}

Originally posted by @sundjly in #75 (comment)

@zyh2123606 zyh2123606 changed the title 经过查看源码,发现是promise异步的原因导致的,因为每次重新进入会生成新的bMapInstance,而自定义覆盖物取到的bMapInstance是上一次的,所以没有加载出来(加载到了上一次的地图实例里面了)。通过setTimeout的hook可以暂时解决这个问题, 这个坑真是难破,有解决的吗 Dec 13, 2018
@JserWang
Copy link
Owner

JserWang commented Jan 19, 2019

在新版本中已重构引入部分。
https://github.com/jser-club/rc-bmap/blob/next/src/core/index.js#L60#L75

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants