mirror of
https://github.com/google-map-react/google-map-react.git
synced 2025-12-08 18:26:32 +00:00
Merge pull request #160 from istarkov/fix-pan-to-move
Fix map moves back in some cases
This commit is contained in:
commit
fb9ee87204
@ -39,7 +39,6 @@
|
||||
"react": "^0.14.0 || ^15.0.0-rc.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"es6-promise": "^3.0.2",
|
||||
"eventemitter3": "^1.1.0",
|
||||
"lodash": "^4.6.1",
|
||||
"point-geometry": "0.0.0",
|
||||
|
||||
@ -231,9 +231,17 @@ export default class GoogleMap extends Component {
|
||||
const centerLatLng = this.geoService_.getCenter();
|
||||
if (nextProps.center) {
|
||||
const nextPropsCenter = latLng2Obj(nextProps.center);
|
||||
if (Math.abs(nextPropsCenter.lat - centerLatLng.lat) +
|
||||
Math.abs(nextPropsCenter.lng - centerLatLng.lng) > kEPS) {
|
||||
this.map_.panTo({lat: nextPropsCenter.lat, lng: nextPropsCenter.lng});
|
||||
const currCenter = latLng2Obj(this.props.center);
|
||||
if (
|
||||
Math.abs(nextPropsCenter.lat - currCenter.lat) +
|
||||
Math.abs(nextPropsCenter.lng - currCenter.lng) > kEPS
|
||||
) {
|
||||
if (
|
||||
Math.abs(nextPropsCenter.lat - centerLatLng.lat) +
|
||||
Math.abs(nextPropsCenter.lng - centerLatLng.lng) > kEPS
|
||||
) {
|
||||
this.map_.panTo({lat: nextPropsCenter.lat, lng: nextPropsCenter.lng});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import find from 'lodash/find';
|
||||
import reduce from 'lodash/reduce';
|
||||
import { Promise } from 'es6-promise';
|
||||
|
||||
let $script_ = null;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user