Skip to content

Commit

Permalink
fix #1011
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzhenn committed Nov 13, 2019
1 parent f6fb0e2 commit 30c552e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
32 changes: 17 additions & 15 deletions src/layer/OverlayLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,22 +233,24 @@ class OverlayLayer extends Layer {
}
}
const map = this.getMap();
if (map && extent && !isNil(extent.xmin)) {
if (map) {
this._getRenderer().onGeometryAdd(geos);
const center = extent.getCenter();
const z = map.getFitZoom(extent);

if (isObject(fitView)) {
const step = isFunction(fitView.step) ? fitView.step : () => undefined;
map.animateTo({
center,
zoom: z,
}, extend({
duration: map.options.zoomAnimationDuration,
easing: 'out',
}, fitView), step);
} else if (fitView === true) {
map.setCenterAndZoom(center, z);
if (extent && !isNil(extent.xmin)) {
const center = extent.getCenter();
const z = map.getFitZoom(extent);

if (isObject(fitView)) {
const step = isFunction(fitView.step) ? fitView.step : () => undefined;
map.animateTo({
center,
zoom: z,
}, extend({
duration: map.options.zoomAnimationDuration,
easing: 'out',
}, fitView), step);
} else if (fitView === true) {
map.setCenterAndZoom(center, z);
}
}
}
/**
Expand Down
4 changes: 2 additions & 2 deletions test/layer/OverlayLayerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ describe('OverlayLayer', function () {
var geo1 = new maptalks.Marker(center1);
var geo2 = new maptalks.Marker(center2);
layer.addGeometry([geo1, geo2], {
duration: 2000,
duration: 100,
easing: 'linear'
});
expect(map.isAnimating()).to.be(true);
Expand All @@ -355,7 +355,7 @@ describe('OverlayLayer', function () {
var geo1 = new maptalks.Marker(center1);
var geo2 = new maptalks.Marker(center2);
layer.addGeometry([geo1, geo2], {
duration: 500,
duration: 100,
easing: 'linear',
step: function(frame) {
if (frame.state.playState === 'finished') {
Expand Down

0 comments on commit 30c552e

Please sign in to comment.