Skip to content

Commit

Permalink
fix #1595 (#1618)
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzhenn authored Mar 3, 2022
1 parent 815157e commit aeb2449
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/geometry/Geometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,10 @@ class Geometry extends JSONAble(Eventable(Handlerable(Class))) {
const symbol = this._sizeSymbol;
const t = (symbol && symbol['lineWidth'] || 1) / 2;
this._fixedExtent.set(-t, -t, t, t);
const dx = (symbol && symbol['lineDx']) || 0;
this._fixedExtent._add([dx, 0]);
const dy = (symbol && symbol['lineDy']) || 0;
this._fixedExtent._add([0, dy]);
return this._fixedExtent;
}

Expand Down Expand Up @@ -1268,12 +1272,13 @@ class Geometry extends JSONAble(Eventable(Handlerable(Class))) {
}

_getSizeSymbol(symbol) {
let symbolSize;
if (isFunctionDefinition(symbol['lineWidth'])) {
symbolSize = loadGeoSymbol({ lineWidth: symbol['lineWidth'] }, this);
const symbolSize = loadGeoSymbol({
lineWidth: symbol['lineWidth'],
lineDx: symbol['lineDx'],
lineDy: symbol['lineDy']
}, this);
if (isFunctionDefinition(symbol['lineWidth']) || isFunctionDefinition(symbol['lineDx']) || isFunctionDefinition(symbol['lineDy'])) {
symbolSize._dynamic = true;
} else {
symbolSize = { lineWidth: symbol['lineWidth'] };
}
return symbolSize;
}
Expand Down
9 changes: 9 additions & 0 deletions test/geometry/LineStringSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,15 @@ describe('Geometry.LineString', function () {
expect(layer.identify({x: 118.84733998413094, y: 32.04636121481619}).length).to.be.above(0);
});

//issue #1595
it('identify line with dx, dy, #1595', function () {
var line = new maptalks.LineString([map.getCenter(), map.getCenter().add(0.001, 0)], { symbol: { lineDx: 20, lineDy: 20, lineWidth :4 }});
layer.addGeometry(line);

var point = new maptalks.Point(map.width / 2 + 20, map.height / 2 + 20);
expect(layer.identifyAtPoint(point).length).to.be.above(0);
});

//issue #522
it('drawn with arrow of vertex-first', function () {
map.setPitch(60);
Expand Down

0 comments on commit aeb2449

Please sign in to comment.