Skip to content

Commit

Permalink
fix centerZ in setCenter, fix maptalks/issues#657 (#2329)
Browse files Browse the repository at this point in the history
* fix centerZ in setCenter, fix maptalks/issues#657

* fix specs
  • Loading branch information
fuzhenn authored May 15, 2024
1 parent 588e229 commit a952f92
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/layer/tile/TileLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1537,7 +1537,7 @@ export type TileLayerOptionsType = LayerOptionsType & {
urlTemplate: string | ((...args) => string);
subdomains?: string[];
spatialReference?: SpatialReferenceType;
tileSize?: number[];
tileSize?: number[] | number;
offset?: number[] | ((...args) => number[]);
tileSystem?: [number, number, number, number];
maxAvailableZoom?: number;
Expand Down
2 changes: 1 addition & 1 deletion src/map/Map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ export class Map extends Handlerable(Eventable(Renderable(Class))) {
this._center = center;
return this;
}
this._centerZ = center.z || 0;
this._centerZ = center.z;
this.onMoveStart();
this._setPrjCenter(pcenter);
this.onMoveEnd(this._parseEventFromCoord(this.getCenter()));
Expand Down
2 changes: 1 addition & 1 deletion test/map/MapSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ describe('Map.Spec', function () {
it('center is changed after setCenter', function () {
var nc = new maptalks.Coordinate(119, 32).copy();
map.setCenter(nc);
expect(map._centerZ === undefined).to.be.ok();

expect(map.getCenter()).to.closeTo(nc);
});
Expand Down Expand Up @@ -555,7 +556,6 @@ describe('Map.Spec', function () {
map._getRenderer()._checkSizeInterval = 10;
// this.timeout(map._getRenderer()._checkSizeInterval * 3);
var center = map.getCenter();
center.z = center.z || 0;
map.once('resize', function (param) {
expect(param).to.be.ok();
//center remains
Expand Down
2 changes: 1 addition & 1 deletion test/map/MapViewHistorySpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('Map View History', function () {
renderer.callInNextFrame(function () {
map.zoomToPreviousView();
var next = map.zoomToNextView();
expect(next.center).to.be.eql([0, 0, 0]);
expect(next.center).to.be.eql([0, 0]);
expect(next.zoom).to.be.eql(zoom - 1);

expect(map.hasNextView()).not.to.be.ok();
Expand Down
2 changes: 1 addition & 1 deletion test/map/control/Control.OverviewSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('Control.Overview', function () {
var overview = new maptalks.control.Overview();
overview.addTo(map);
map.on('viewchange', function () {
expect(overview._overview.getCenter().toArray()).to.be.eql([0, 0, 0]);
expect(overview._overview.getCenter().toArray()).to.be.eql([0, 0]);
done();
});
map.setCenter([0, 0]);
Expand Down
4 changes: 2 additions & 2 deletions test/map/control/Control.ResetSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('Control.Reset', function () {
happen.click(control._reset);

expect(map.getView()).to.eql({
center: [120, 20, 0],
center: [120, 20],
zoom: 8,
bearing: 10,
pitch: 30
Expand All @@ -51,7 +51,7 @@ describe('Control.Reset', function () {
happen.click(control._reset);

expect(map.getView()).to.eql({
center: [118, 32, 0],
center: [118, 32],
zoom: 5,
bearing: 0,
pitch: 0
Expand Down

0 comments on commit a952f92

Please sign in to comment.