Skip to content

Commit

Permalink
fix(Map): 中心点update代码优化
Browse files Browse the repository at this point in the history
  • Loading branch information
Junior2Ran committed Jun 21, 2019
1 parent 91fd422 commit c2240f8
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/dist/react-bmap.min.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions docs/examples/build/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17888,7 +17888,7 @@ var App = function (_Component) {
value: function getEvents() {
return {
click: function click(e) {
console.log('map click event', e, type);
console.log('map click event', e.type);
}
};
}
Expand Down Expand Up @@ -20516,8 +20516,8 @@ var Map = function (_Component) {
this.map.centerAndZoom(center);
}
} else {
var isCenterChanged = preCenter && center && preCenter.lng != center.lng || preCenter.lat != center.lat || this.props.forceUpdate;
var isZoomChanged = prevProps.zoom !== this.props.zoom && this.props.zoom || this.props.forceUpdate;
var isCenterChanged = preCenter && center && (preCenter.lng != center.lng || preCenter.lat != center.lat || this.props.forceUpdate);
var isZoomChanged = prevProps.zoom !== this.props.zoom && (this.props.zoom || this.props.forceUpdate);
var center = new BMap.Point(center.lng, center.lat);
if (isCenterChanged && isZoomChanged) {
this.map.centerAndZoom(center, this.props.zoom);
Expand Down Expand Up @@ -20619,7 +20619,7 @@ var Map = function (_Component) {
}
return _react2.default.createElement(
'div',
{ style: style, key: this.props.key },
{ style: style, key: this.props.keys },
_react2.default.createElement(
'div',
{ ref: 'map', className: this.props.className, style: { height: '100%' } },
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/components/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default class App extends Component {
getEvents() {
return {
click: (e) => {
console.log('map click event', e, type);
console.log('map click event', e.type);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-bmap",
"version": "1.0.99",
"version": "1.0.100",
"description": "react-bmap",
"main": "lib/index.js",
"contributors": [
Expand Down
6 changes: 3 additions & 3 deletions src/components/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ export default class Map extends Component {
this.map.centerAndZoom(center);
}
} else {
var isCenterChanged = preCenter && center && preCenter.lng != center.lng || preCenter.lat != center.lat || this.props.forceUpdate;
var isZoomChanged = prevProps.zoom !== this.props.zoom && this.props.zoom || this.props.forceUpdate;
var isCenterChanged = preCenter && center && (preCenter.lng != center.lng || preCenter.lat != center.lat || this.props.forceUpdate);
var isZoomChanged = prevProps.zoom !== this.props.zoom && (this.props.zoom || this.props.forceUpdate);
var center = new BMap.Point(center.lng, center.lat);
if (isCenterChanged && isZoomChanged) {
this.map.centerAndZoom(center, this.props.zoom);
Expand Down Expand Up @@ -205,7 +205,7 @@ export default class Map extends Component {
style[key] = this.props.style[key];
}
return (
<div style={style} key={this.props.key}>
<div style={style} key={this.props.keys}>
<div ref='map' className={this.props.className} style={{height: '100%'}}>
加载地图中...
</div>
Expand Down

0 comments on commit c2240f8

Please sign in to comment.