@mapless/core 1.0.16 → 1.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +49 -43
- package/dist/types/Mapless/path/strategies/base.d.ts +1 -0
- package/dist/types/Mapless/path/strategies/base.d.ts.map +1 -1
- package/dist/types/Mapless/path/strategies/click.d.ts.map +1 -1
- package/dist/types/Mapless/path/strategies/free.d.ts +1 -1
- package/dist/types/Mapless/path/strategies/free.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -20579,6 +20579,7 @@ class PathCollectionStrategy {
|
|
|
20579
20579
|
callbacks = {};
|
|
20580
20580
|
isActive = false;
|
|
20581
20581
|
points = [];
|
|
20582
|
+
isDestroyed = false;
|
|
20582
20583
|
initialize(map, callbacks) {
|
|
20583
20584
|
this.map = map;
|
|
20584
20585
|
this.callbacks = callbacks;
|
|
@@ -20597,6 +20598,7 @@ class PathCollectionStrategy {
|
|
|
20597
20598
|
this.onStopCollection();
|
|
20598
20599
|
}
|
|
20599
20600
|
destroy() {
|
|
20601
|
+
this.isDestroyed = true;
|
|
20600
20602
|
this.stop();
|
|
20601
20603
|
this.removeEventListeners();
|
|
20602
20604
|
this.map = null;
|
|
@@ -20727,7 +20729,7 @@ class ClickStrategy extends PathCollectionStrategy {
|
|
|
20727
20729
|
const canvas = this.map.getCanvas();
|
|
20728
20730
|
if (canvas) canvas.style.cursor = '';
|
|
20729
20731
|
this.clearPoints();
|
|
20730
|
-
this.updateLayers();
|
|
20732
|
+
if (!this.isDestroyed) this.updateLayers();
|
|
20731
20733
|
}
|
|
20732
20734
|
handleClick = (e)=>{
|
|
20733
20735
|
if (!this.isActive) return;
|
|
@@ -20759,36 +20761,38 @@ class ClickStrategy extends PathCollectionStrategy {
|
|
|
20759
20761
|
}
|
|
20760
20762
|
};
|
|
20761
20763
|
updateLayers() {
|
|
20762
|
-
if (!this.map) return;
|
|
20763
|
-
|
|
20764
|
-
|
|
20765
|
-
|
|
20766
|
-
|
|
20767
|
-
|
|
20768
|
-
|
|
20769
|
-
|
|
20770
|
-
|
|
20771
|
-
p.lat
|
|
20772
|
-
])
|
|
20773
|
-
},
|
|
20774
|
-
properties: {}
|
|
20775
|
-
});
|
|
20776
|
-
pointSource?.setData({
|
|
20777
|
-
type: 'FeatureCollection',
|
|
20778
|
-
features: this.points.map((p, index)=>({
|
|
20779
|
-
type: 'Feature',
|
|
20780
|
-
geometry: {
|
|
20781
|
-
type: 'Point',
|
|
20782
|
-
coordinates: [
|
|
20764
|
+
if (!this.map || this.isDestroyed) return;
|
|
20765
|
+
try {
|
|
20766
|
+
const lineSource = this.map.getSource(this.sourceId);
|
|
20767
|
+
const pointSource = this.map.getSource(this.pointSourceId);
|
|
20768
|
+
lineSource?.setData({
|
|
20769
|
+
type: 'Feature',
|
|
20770
|
+
geometry: {
|
|
20771
|
+
type: 'LineString',
|
|
20772
|
+
coordinates: this.points.map((p)=>[
|
|
20783
20773
|
p.lng,
|
|
20784
20774
|
p.lat
|
|
20785
|
-
]
|
|
20786
|
-
|
|
20787
|
-
|
|
20788
|
-
|
|
20789
|
-
|
|
20790
|
-
|
|
20791
|
-
|
|
20775
|
+
])
|
|
20776
|
+
},
|
|
20777
|
+
properties: {}
|
|
20778
|
+
});
|
|
20779
|
+
pointSource?.setData({
|
|
20780
|
+
type: 'FeatureCollection',
|
|
20781
|
+
features: this.points.map((p, index)=>({
|
|
20782
|
+
type: 'Feature',
|
|
20783
|
+
geometry: {
|
|
20784
|
+
type: 'Point',
|
|
20785
|
+
coordinates: [
|
|
20786
|
+
p.lng,
|
|
20787
|
+
p.lat
|
|
20788
|
+
]
|
|
20789
|
+
},
|
|
20790
|
+
properties: {
|
|
20791
|
+
index: index + 1
|
|
20792
|
+
}
|
|
20793
|
+
}))
|
|
20794
|
+
});
|
|
20795
|
+
} catch {}
|
|
20792
20796
|
}
|
|
20793
20797
|
undo() {
|
|
20794
20798
|
if (this.points.length > 0) {
|
|
@@ -20890,7 +20894,7 @@ class FreeStrategy extends PathCollectionStrategy {
|
|
|
20890
20894
|
this.isDragging = false;
|
|
20891
20895
|
this.clearPoints();
|
|
20892
20896
|
this.lastPoint = null;
|
|
20893
|
-
this.updateLayer();
|
|
20897
|
+
if (!this.isDestroyed) this.updateLayer();
|
|
20894
20898
|
}
|
|
20895
20899
|
handleMouseDown = (e)=>{
|
|
20896
20900
|
if (!this.isActive || !this.map) return;
|
|
@@ -20956,19 +20960,21 @@ class FreeStrategy extends PathCollectionStrategy {
|
|
|
20956
20960
|
return distance >= minDistance;
|
|
20957
20961
|
}
|
|
20958
20962
|
updateLayer() {
|
|
20959
|
-
if (!this.map) return;
|
|
20960
|
-
|
|
20961
|
-
|
|
20962
|
-
|
|
20963
|
-
|
|
20964
|
-
|
|
20965
|
-
|
|
20966
|
-
|
|
20967
|
-
|
|
20968
|
-
|
|
20969
|
-
|
|
20970
|
-
|
|
20971
|
-
|
|
20963
|
+
if (!this.map || this.isDestroyed) return;
|
|
20964
|
+
try {
|
|
20965
|
+
const source = this.map.getSource(this.sourceId);
|
|
20966
|
+
source?.setData({
|
|
20967
|
+
type: 'Feature',
|
|
20968
|
+
geometry: {
|
|
20969
|
+
type: 'LineString',
|
|
20970
|
+
coordinates: this.points.map((p)=>[
|
|
20971
|
+
p.lng,
|
|
20972
|
+
p.lat
|
|
20973
|
+
])
|
|
20974
|
+
},
|
|
20975
|
+
properties: {}
|
|
20976
|
+
});
|
|
20977
|
+
} catch {}
|
|
20972
20978
|
}
|
|
20973
20979
|
}
|
|
20974
20980
|
class PathTracker {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../../src/Mapless/path/strategies/base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EACvB,yBAAyB,EACzB,SAAS,EACT,WAAW,EACZ,MAAM,SAAS,CAAC;AAEjB;;;GAGG;AACH,MAAM,CAAC,OAAO,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QAAQ,CAAC,mBAAmB,IAAI,IAAI;IAE9C;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,oBAAoB,IAAI,IAAI;IAE/C;;OAEG;IACH,SAAS,CAAC,iBAAiB,IAAI,IAAI;IAInC;;OAEG;IACH,SAAS,CAAC,gBAAgB,IAAI,IAAI;IAIlC;;OAEG;IACH,SAAS,CAAC,iBAAiB,CACzB,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,SAAS,GAChB,MAAM;IAST;;OAEG;IACH,SAAS,CAAC,qBAAqB,CAC7B,CAAC,EAAE,QAAQ,CAAC,aAAa,GACxB,SAAS;CAOb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"click.d.ts","sourceRoot":"","sources":["../../../../../src/Mapless/path/strategies/click.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,sBAAsB,MAAM,QAAQ,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,sBAAsB;IAC/D,QAAQ,CAAC,IAAI,WAAW;IAExB,OAAO,CAAC,QAAQ,CAAM;IACtB,OAAO,CAAC,OAAO,CAAM;IACrB,OAAO,CAAC,aAAa,CAAM;IAC3B,OAAO,CAAC,YAAY,CAAM;IAC1B,OAAO,CAAC,OAAO,CAA0B;IAEzC;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI;IAI7C,SAAS,CAAC,mBAAmB,IAAI,IAAI;IA4DrC,SAAS,CAAC,oBAAoB,IAAI,IAAI;IAiBtC,SAAS,CAAC,iBAAiB,IAAI,IAAI;IAUnC,SAAS,CAAC,gBAAgB,IAAI,IAAI;
|
|
1
|
+
{"version":3,"file":"click.d.ts","sourceRoot":"","sources":["../../../../../src/Mapless/path/strategies/click.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,sBAAsB,MAAM,QAAQ,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,sBAAsB;IAC/D,QAAQ,CAAC,IAAI,WAAW;IAExB,OAAO,CAAC,QAAQ,CAAM;IACtB,OAAO,CAAC,OAAO,CAAM;IACrB,OAAO,CAAC,aAAa,CAAM;IAC3B,OAAO,CAAC,YAAY,CAAM;IAC1B,OAAO,CAAC,OAAO,CAA0B;IAEzC;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI;IAI7C,SAAS,CAAC,mBAAmB,IAAI,IAAI;IA4DrC,SAAS,CAAC,oBAAoB,IAAI,IAAI;IAiBtC,SAAS,CAAC,iBAAiB,IAAI,IAAI;IAUnC,SAAS,CAAC,gBAAgB,IAAI,IAAI;IAalC;;OAEG;IACH,OAAO,CAAC,WAAW,CAkBjB;IAEF;;OAEG;IACH,OAAO,CAAC,iBAAiB,CAiBvB;IAEF;;OAEG;IACH,OAAO,CAAC,aAAa,CAkBnB;IAEF;;OAEG;IACH,OAAO,CAAC,YAAY;IAwCpB;;OAEG;IACH,OAAO,CAAC,IAAI;IAQZ;;OAEG;IACI,QAAQ,IAAI,IAAI;IA0BvB;;OAEG;IACH,OAAO,CAAC,MAAM;CAOf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"free.d.ts","sourceRoot":"","sources":["../../../../../src/Mapless/path/strategies/free.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"free.d.ts","sourceRoot":"","sources":["../../../../../src/Mapless/path/strategies/free.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA0B,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,sBAAsB,MAAM,QAAQ,CAAC;AAE5C;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,sBAAsB;IAC9D,QAAQ,CAAC,IAAI,UAAU;IAEvB,OAAO,CAAC,QAAQ,CAAM;IACtB,OAAO,CAAC,OAAO,CAAM;IACrB,OAAO,CAAC,OAAO,CAA0B;IACzC,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,SAAS,CAA0B;IAE3C;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI;IAI7C,SAAS,CAAC,mBAAmB,IAAI,IAAI;IAsCrC,SAAS,CAAC,oBAAoB,IAAI,IAAI;IAgBtC,SAAS,CAAC,iBAAiB,IAAI,IAAI;IAWnC,SAAS,CAAC,gBAAgB,IAAI,IAAI;IAelC;;OAEG;IACH,OAAO,CAAC,eAAe,CAoBrB;IAEF;;OAEG;IACH,OAAO,CAAC,eAAe,CAcrB;IAEF;;OAEG;IACH,OAAO,CAAC,aAAa,CAgCnB;IAEF;;;OAGG;IACH,OAAO,CAAC,cAAc;IAmBtB;;OAEG;IACH,OAAO,CAAC,WAAW;CAkBpB"}
|