Skip to content

Commit

Permalink
fix pointToContainerPoint with bearing
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzhenn committed Nov 13, 2017
1 parent 53a3869 commit c9d6ade
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/map/Map.Camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ Map.include(/** @lends Map.prototype */{
// if you want to rotate the map after up an incline,please rotateZ like this:
// let up = new vec3(0,1,0);
// up.rotateZ(target,radians);
const up = [Math.sin(bearing) * dist, Math.cos(bearing) * dist, 0];
const d = dist || 1;
const up = [Math.sin(bearing) * d, Math.cos(bearing) * d, 0];
const m = this.cameraWorldMatrix || createMat4();
lookAt(m, [cx, cy, cz], [center2D.x, center2D.y, 0], up);

Expand Down
3 changes: 1 addition & 2 deletions src/renderer/layer/tilelayer/TileLayerCanvasRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,7 @@ class TileLayerCanvasRenderer extends CanvasRenderer {
}
x = y = 0;
}
Canvas2D.image(ctx, tileImage,
x, y, w, h);
Canvas2D.image(ctx, tileImage, x, y, w, h);
if (this.layer.options['debug']) {
const p = new Point(x, y),
color = this.layer.options['debugOutline'],
Expand Down
38 changes: 38 additions & 0 deletions test/map/ProjectionSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,44 @@ describe('Map.Projection', function () {
expect(map.computeGeometryArea(polygon)).to.be.eql(100);
expect(map.locate([0, 0], 10, 10)).to.be.eql(new maptalks.Coordinate(10, 10));
});

it('fit to extent in IDENTITY projection', function () {
// a bug reported by @1dent1ty in 2017-11-09
map.setSpatialReference({
projection:'identity',
resolutions: [
156543.03392804097,
78271.51696402048,
9135.75848201024,
19567.87924100512,
9783.93962050256,
4891.96981025128,
2445.98490512564,
1222.99245256282,
611.49622628141,
305.748113140705,
152.8740565703525,
76.43702828517625,
38.21851414258813,
19.109257071294063,
9.554628535647032,
4.777314267823516,
2.388657133911758,
1.194328566955879,
0.5971642834779395,
0.29858214173896974
],
fullExtent : {
'top': 6378137 * Math.PI,
'left': -6378137 * Math.PI,
'bottom': -6378137 * Math.PI,
'right': 6378137 * Math.PI
}
});
map.setMaxExtent(new maptalks.Extent([453136.979,4078961.066,533971.862,4145348.864]));
var z = map.getFitZoom(map.getMaxExtent());
expect(z).to.be.eql(10);
});
});

describe('change to Baidu', function () {
Expand Down

0 comments on commit c9d6ade

Please sign in to comment.