@orbat-mapper/tactical-draw-adapter-maplibre 0.2.0-alpha.1 → 0.2.0-alpha.2
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.d.mts +1 -0
- package/dist/index.mjs +10 -6
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -16,6 +16,7 @@ interface MapLibreViewToken {
|
|
|
16
16
|
declare class MapLibreAdapter extends BaseMapAdapter<MapLibreLayerHandle, MapLibreEventToken, MapLibreViewToken> {
|
|
17
17
|
private map;
|
|
18
18
|
constructor(map: maplibregl.Map);
|
|
19
|
+
private toContinuousLng;
|
|
19
20
|
protected createLayer(layerId: LayerId, style?: StyleOptions): MapLibreLayerHandle;
|
|
20
21
|
protected destroyLayer(handle: MapLibreLayerHandle): void;
|
|
21
22
|
protected applyFeatureOps(layerId: LayerId, ops: FeatureOps): void;
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { project, unproject } from "@orbat-mapper/control-measures";
|
|
2
|
-
import { BaseMapAdapter, PointerCallbackHub, TOUCH_HIT_TOLERANCE_PX, bindAbortable, pickHitTolerance, tryControlMeasureIdFromFeature } from "@orbat-mapper/tactical-draw";
|
|
2
|
+
import { BaseMapAdapter, PointerCallbackHub, TOUCH_HIT_TOLERANCE_PX, bindAbortable, nearestWorldCopyLng, pickHitTolerance, tryControlMeasureIdFromFeature } from "@orbat-mapper/tactical-draw";
|
|
3
3
|
//#region src/ml-adapter.ts
|
|
4
4
|
function emptyFC() {
|
|
5
5
|
return {
|
|
@@ -212,6 +212,9 @@ var MapLibreAdapter = class extends BaseMapAdapter {
|
|
|
212
212
|
super();
|
|
213
213
|
this.map = map;
|
|
214
214
|
}
|
|
215
|
+
toContinuousLng(lng) {
|
|
216
|
+
return nearestWorldCopyLng(lng, this.map.getCenter().lng);
|
|
217
|
+
}
|
|
215
218
|
createLayer(layerId, style) {
|
|
216
219
|
const sourceId = `${layerId}-src`;
|
|
217
220
|
this.map.addSource(sourceId, {
|
|
@@ -302,7 +305,7 @@ var MapLibreAdapter = class extends BaseMapAdapter {
|
|
|
302
305
|
attachNativeEvent(type, onEvent) {
|
|
303
306
|
const mlEvent = type === "pointermove" ? "mousemove" : type === "dblclick" ? "dblclick" : "click";
|
|
304
307
|
const fn = (e) => {
|
|
305
|
-
onEvent([e.lngLat.lng, e.lngLat.lat], [e.point.x, e.point.y], e);
|
|
308
|
+
onEvent([this.toContinuousLng(e.lngLat.lng), e.lngLat.lat], [e.point.x, e.point.y], e);
|
|
306
309
|
};
|
|
307
310
|
this.map.on(mlEvent, fn);
|
|
308
311
|
return {
|
|
@@ -329,6 +332,7 @@ var MapLibreAdapter = class extends BaseMapAdapter {
|
|
|
329
332
|
}
|
|
330
333
|
createEditPointerDriver() {
|
|
331
334
|
const map = this.map;
|
|
335
|
+
const toContinuousLng = (lng) => this.toContinuousLng(lng);
|
|
332
336
|
const hub = new PointerCallbackHub();
|
|
333
337
|
let dragPanWasEnabled = false;
|
|
334
338
|
let disposed = false;
|
|
@@ -403,12 +407,12 @@ var MapLibreAdapter = class extends BaseMapAdapter {
|
|
|
403
407
|
}
|
|
404
408
|
},
|
|
405
409
|
toPixel(lonLat) {
|
|
406
|
-
const p = map.project(lonLat);
|
|
410
|
+
const p = map.project([toContinuousLng(lonLat[0]), lonLat[1]]);
|
|
407
411
|
return [p.x, p.y];
|
|
408
412
|
},
|
|
409
413
|
fromPixel(pixel) {
|
|
410
414
|
const ll = map.unproject(pixel);
|
|
411
|
-
return [ll.lng, ll.lat];
|
|
415
|
+
return [toContinuousLng(ll.lng), ll.lat];
|
|
412
416
|
},
|
|
413
417
|
dispose() {
|
|
414
418
|
if (disposed) return;
|
|
@@ -472,7 +476,7 @@ var MapLibreAdapter = class extends BaseMapAdapter {
|
|
|
472
476
|
return project(position[0], position[1]);
|
|
473
477
|
}
|
|
474
478
|
getPixelFromCoordinate(position) {
|
|
475
|
-
const point = this.map.project(position);
|
|
479
|
+
const point = this.map.project([this.toContinuousLng(position[0]), position[1]]);
|
|
476
480
|
return [point.x, point.y];
|
|
477
481
|
}
|
|
478
482
|
getViewportSize() {
|
|
@@ -534,7 +538,7 @@ var MapLibreAdapter = class extends BaseMapAdapter {
|
|
|
534
538
|
id: cmId,
|
|
535
539
|
feature: geojson,
|
|
536
540
|
pixel: [x, y],
|
|
537
|
-
coordinate: [e.lngLat.lng, e.lngLat.lat],
|
|
541
|
+
coordinate: [this.toContinuousLng(e.lngLat.lng), e.lngLat.lat],
|
|
538
542
|
originalEvent
|
|
539
543
|
});
|
|
540
544
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orbat-mapper/tactical-draw-adapter-maplibre",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.2",
|
|
4
4
|
"description": "MapLibre GL JS engine adapter for @orbat-mapper/tactical-draw. Draw and edit tactical control measures (MIL-STD-2525 / APP-6) on a MapLibre map.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Orbat Mapper",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@orbat-mapper/control-measures": "^0.2.0-alpha.
|
|
41
|
-
"@orbat-mapper/tactical-draw": "^0.2.0-alpha.
|
|
40
|
+
"@orbat-mapper/control-measures": "^0.2.0-alpha.7",
|
|
41
|
+
"@orbat-mapper/tactical-draw": "^0.2.0-alpha.6"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"maplibre-gl": ">=4.0.0 <6.0.0"
|