Merge pull request #160 from istarkov/fix-pan-to-move

Fix map moves back in some cases
This commit is contained in:
Ivan Starkov 2016-05-31 17:16:42 +03:00
commit fb9ee87204
3 changed files with 11 additions and 5 deletions

View File

@ -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",

View File

@ -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});
}
}
}

View File

@ -1,6 +1,5 @@
import find from 'lodash/find';
import reduce from 'lodash/reduce';
import { Promise } from 'es6-promise';
let $script_ = null;