Skip to content

Commit aeb2449

Browse files
authored
fix #1595 (#1618)
1 parent 815157e commit aeb2449

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

src/geometry/Geometry.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,10 @@ class Geometry extends JSONAble(Eventable(Handlerable(Class))) {
464464
const symbol = this._sizeSymbol;
465465
const t = (symbol && symbol['lineWidth'] || 1) / 2;
466466
this._fixedExtent.set(-t, -t, t, t);
467+
const dx = (symbol && symbol['lineDx']) || 0;
468+
this._fixedExtent._add([dx, 0]);
469+
const dy = (symbol && symbol['lineDy']) || 0;
470+
this._fixedExtent._add([0, dy]);
467471
return this._fixedExtent;
468472
}
469473

@@ -1268,12 +1272,13 @@ class Geometry extends JSONAble(Eventable(Handlerable(Class))) {
12681272
}
12691273

12701274
_getSizeSymbol(symbol) {
1271-
let symbolSize;
1272-
if (isFunctionDefinition(symbol['lineWidth'])) {
1273-
symbolSize = loadGeoSymbol({ lineWidth: symbol['lineWidth'] }, this);
1275+
const symbolSize = loadGeoSymbol({
1276+
lineWidth: symbol['lineWidth'],
1277+
lineDx: symbol['lineDx'],
1278+
lineDy: symbol['lineDy']
1279+
}, this);
1280+
if (isFunctionDefinition(symbol['lineWidth']) || isFunctionDefinition(symbol['lineDx']) || isFunctionDefinition(symbol['lineDy'])) {
12741281
symbolSize._dynamic = true;
1275-
} else {
1276-
symbolSize = { lineWidth: symbol['lineWidth'] };
12771282
}
12781283
return symbolSize;
12791284
}

test/geometry/LineStringSpec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,15 @@ describe('Geometry.LineString', function () {
303303
expect(layer.identify({x: 118.84733998413094, y: 32.04636121481619}).length).to.be.above(0);
304304
});
305305

306+
//issue #1595
307+
it('identify line with dx, dy, #1595', function () {
308+
var line = new maptalks.LineString([map.getCenter(), map.getCenter().add(0.001, 0)], { symbol: { lineDx: 20, lineDy: 20, lineWidth :4 }});
309+
layer.addGeometry(line);
310+
311+
var point = new maptalks.Point(map.width / 2 + 20, map.height / 2 + 20);
312+
expect(layer.identifyAtPoint(point).length).to.be.above(0);
313+
});
314+
306315
//issue #522
307316
it('drawn with arrow of vertex-first', function () {
308317
map.setPitch(60);

0 commit comments

Comments
 (0)