@edgepdf/viewer-js 0.0.31 → 0.0.33
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/README.md +500 -100
- package/dist/index.css +940 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +143 -116
- package/dist/lib/coordinate-mapper.d.ts +3 -3
- package/dist/lib/coordinate-mapper.d.ts.map +1 -1
- package/dist/lib/marker-action-controls.d.ts.map +1 -1
- package/dist/lib/marker-delete-popup.d.ts.map +1 -1
- package/dist/lib/marker-edit-popup.d.ts.map +1 -1
- package/dist/lib/marker-manager.d.ts +40 -10
- package/dist/lib/marker-manager.d.ts.map +1 -1
- package/dist/lib/tile-layer-manager.d.ts +5 -5
- package/dist/lib/tile-layer-manager.d.ts.map +1 -1
- package/dist/lib/viewer.d.ts +30 -4
- package/dist/lib/viewer.d.ts.map +1 -1
- package/dist/lib/zoom-controller.d.ts +2 -2
- package/dist/lib/zoom-controller.d.ts.map +1 -1
- package/dist/lib/zoom-controls.d.ts.map +1 -1
- package/package.json +1 -5
- package/dist/lib/inject-styles.d.ts +0 -17
- package/dist/lib/inject-styles.d.ts.map +0 -1
- package/dist/lib/leaflet-loader.d.ts +0 -26
- package/dist/lib/leaflet-loader.d.ts.map +0 -1
- package/dist/styles.css +0 -1038
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,cAAc,CAAC;AAEtB,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,YAAY,EACV,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,YAAY,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGlD,YAAY,EACV,SAAS,EACT,UAAU,EACV,YAAY,EACZ,aAAa,EACb,WAAW,EACX,MAAM,EACN,UAAU,EACV,UAAU,EACV,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,mBAAmB,EACnB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -9575,30 +9575,11 @@ var require_leaflet_src = __commonJS({
|
|
|
9575
9575
|
}
|
|
9576
9576
|
});
|
|
9577
9577
|
|
|
9578
|
-
// packages/viewer-js/src/lib/
|
|
9579
|
-
var
|
|
9580
|
-
|
|
9581
|
-
|
|
9582
|
-
|
|
9583
|
-
return L2;
|
|
9584
|
-
}
|
|
9585
|
-
if (leafletLoadPromise) {
|
|
9586
|
-
return leafletLoadPromise;
|
|
9587
|
-
}
|
|
9588
|
-
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
9589
|
-
throw new Error(
|
|
9590
|
-
"Leaflet requires a browser environment. This code can only be used in the browser."
|
|
9591
|
-
);
|
|
9592
|
-
}
|
|
9593
|
-
leafletLoadPromise = Promise.resolve().then(() => __toESM(require_leaflet_src(), 1)).then((leafletModule) => {
|
|
9594
|
-
L2 = leafletModule.default;
|
|
9595
|
-
return L2;
|
|
9596
|
-
});
|
|
9597
|
-
return leafletLoadPromise;
|
|
9598
|
-
}
|
|
9599
|
-
function getLeaflet() {
|
|
9600
|
-
return L2;
|
|
9601
|
-
}
|
|
9578
|
+
// packages/viewer-js/src/lib/viewer.ts
|
|
9579
|
+
var import_leaflet4 = __toESM(require_leaflet_src(), 1);
|
|
9580
|
+
|
|
9581
|
+
// packages/viewer-js/src/lib/tile-layer-manager.ts
|
|
9582
|
+
var import_leaflet = __toESM(require_leaflet_src(), 1);
|
|
9602
9583
|
|
|
9603
9584
|
// packages/utils/dist/index.js
|
|
9604
9585
|
var S3_PREFIX = {
|
|
@@ -9608,6 +9589,12 @@ var S3_PREFIX = {
|
|
|
9608
9589
|
PROCESSED: "processed"
|
|
9609
9590
|
};
|
|
9610
9591
|
var MAX_ZOOM_LEVEL = 4;
|
|
9592
|
+
var MARKER_SPEC = {
|
|
9593
|
+
WIDTH: 30,
|
|
9594
|
+
HEIGHT: 40,
|
|
9595
|
+
ANCHOR_X: 16,
|
|
9596
|
+
ANCHOR_Y: 36
|
|
9597
|
+
};
|
|
9611
9598
|
function calculateTileCount(imageSize, tileSize, zoom) {
|
|
9612
9599
|
if (imageSize <= 0 || tileSize <= 0 || zoom < 0) {
|
|
9613
9600
|
return 0;
|
|
@@ -9682,13 +9669,12 @@ var TileLayerManager = class {
|
|
|
9682
9669
|
*
|
|
9683
9670
|
* @throws {Error} If tile layer creation fails
|
|
9684
9671
|
*/
|
|
9685
|
-
|
|
9672
|
+
createTileLayer(map) {
|
|
9686
9673
|
if (this.tileLayer) {
|
|
9687
9674
|
console.warn("Tile layer already created. Use removeTileLayer() first.");
|
|
9688
9675
|
return this.tileLayer;
|
|
9689
9676
|
}
|
|
9690
9677
|
try {
|
|
9691
|
-
const L3 = getLeaflet() || await loadLeaflet();
|
|
9692
9678
|
const { imageInfo, tileUrl, keepBuffer, updateInterval } = this.config;
|
|
9693
9679
|
const bounds = this.calculateTileBounds();
|
|
9694
9680
|
const tileLayerOptions = {
|
|
@@ -9711,7 +9697,7 @@ var TileLayerManager = class {
|
|
|
9711
9697
|
className: "seamless-tiles"
|
|
9712
9698
|
// CSS class for styling
|
|
9713
9699
|
};
|
|
9714
|
-
this.tileLayer =
|
|
9700
|
+
this.tileLayer = import_leaflet.default.tileLayer(tileUrl, tileLayerOptions);
|
|
9715
9701
|
if (map) {
|
|
9716
9702
|
this.setupEventListeners(map);
|
|
9717
9703
|
}
|
|
@@ -9825,6 +9811,7 @@ var TileLayerManager = class {
|
|
|
9825
9811
|
};
|
|
9826
9812
|
|
|
9827
9813
|
// packages/viewer-js/src/lib/coordinate-mapper.ts
|
|
9814
|
+
var import_leaflet2 = __toESM(require_leaflet_src(), 1);
|
|
9828
9815
|
var CoordinateMapper = class {
|
|
9829
9816
|
imageInfo;
|
|
9830
9817
|
/**
|
|
@@ -9964,14 +9951,13 @@ var CoordinateMapper = class {
|
|
|
9964
9951
|
* // [[0, 0], [512, 512]] for minZoom 0 with tileSize 256
|
|
9965
9952
|
* ```
|
|
9966
9953
|
*/
|
|
9967
|
-
|
|
9968
|
-
const L3 = getLeaflet() || await loadLeaflet();
|
|
9954
|
+
calculateMapBounds() {
|
|
9969
9955
|
const tileSize = this.imageInfo.tileSize || 256;
|
|
9970
9956
|
const minZoom = this.imageInfo.minZoom || 0;
|
|
9971
9957
|
const gridSize = Math.pow(2, minZoom + 1);
|
|
9972
9958
|
const boundsWidth = gridSize * tileSize;
|
|
9973
9959
|
const boundsHeight = gridSize * tileSize;
|
|
9974
|
-
return
|
|
9960
|
+
return import_leaflet2.default.latLngBounds([0, 0], [boundsHeight, boundsWidth]);
|
|
9975
9961
|
}
|
|
9976
9962
|
/**
|
|
9977
9963
|
* Validates Leaflet coordinates and checks bounds
|
|
@@ -10029,10 +10015,9 @@ var CoordinateMapper = class {
|
|
|
10029
10015
|
*
|
|
10030
10016
|
* @returns Custom CRS instance
|
|
10031
10017
|
*/
|
|
10032
|
-
|
|
10033
|
-
|
|
10034
|
-
|
|
10035
|
-
transformation: new L3.Transformation(1, 0, 1, 0)
|
|
10018
|
+
createCustomCRS() {
|
|
10019
|
+
return import_leaflet2.default.extend({}, import_leaflet2.default.CRS.Simple, {
|
|
10020
|
+
transformation: new import_leaflet2.default.Transformation(1, 0, 1, 0)
|
|
10036
10021
|
});
|
|
10037
10022
|
}
|
|
10038
10023
|
/**
|
|
@@ -10411,14 +10396,12 @@ var ZoomController = class {
|
|
|
10411
10396
|
}
|
|
10412
10397
|
};
|
|
10413
10398
|
|
|
10399
|
+
// packages/viewer-js/src/lib/marker-manager.ts
|
|
10400
|
+
var import_leaflet3 = __toESM(require_leaflet_src(), 1);
|
|
10401
|
+
|
|
10414
10402
|
// packages/viewer-js/src/lib/marker-edit-popup.ts
|
|
10415
10403
|
var currentEditPopup = null;
|
|
10416
10404
|
function createEditPopup(options) {
|
|
10417
|
-
if (typeof document === "undefined") {
|
|
10418
|
-
throw new Error(
|
|
10419
|
-
"createEditPopup requires a browser environment (document is not available)"
|
|
10420
|
-
);
|
|
10421
|
-
}
|
|
10422
10405
|
if (currentEditPopup && currentEditPopup.parentElement) {
|
|
10423
10406
|
currentEditPopup.parentElement.removeChild(currentEditPopup);
|
|
10424
10407
|
currentEditPopup = null;
|
|
@@ -10542,11 +10525,6 @@ function createEditPopup(options) {
|
|
|
10542
10525
|
// packages/viewer-js/src/lib/marker-delete-popup.ts
|
|
10543
10526
|
var currentDeletePopup = null;
|
|
10544
10527
|
function createDeletePopup(options) {
|
|
10545
|
-
if (typeof document === "undefined") {
|
|
10546
|
-
throw new Error(
|
|
10547
|
-
"createDeletePopup requires a browser environment (document is not available)"
|
|
10548
|
-
);
|
|
10549
|
-
}
|
|
10550
10528
|
if (currentDeletePopup && currentDeletePopup.parentElement) {
|
|
10551
10529
|
currentDeletePopup.parentElement.removeChild(currentDeletePopup);
|
|
10552
10530
|
currentDeletePopup = null;
|
|
@@ -10642,7 +10620,7 @@ var MarkerManager = class {
|
|
|
10642
10620
|
imageInfo;
|
|
10643
10621
|
markers = /* @__PURE__ */ new Map();
|
|
10644
10622
|
leafletMarkers = /* @__PURE__ */ new Map();
|
|
10645
|
-
markerLayerGroup
|
|
10623
|
+
markerLayerGroup;
|
|
10646
10624
|
eventListeners = /* @__PURE__ */ new Map();
|
|
10647
10625
|
selectedIds = /* @__PURE__ */ new Set();
|
|
10648
10626
|
activeMarkerId = null;
|
|
@@ -10687,16 +10665,7 @@ var MarkerManager = class {
|
|
|
10687
10665
|
this.map = options.map;
|
|
10688
10666
|
this.coordinateMapper = options.coordinateMapper;
|
|
10689
10667
|
this.imageInfo = options.imageInfo;
|
|
10690
|
-
|
|
10691
|
-
/**
|
|
10692
|
-
* Initializes the marker layer group (called after Leaflet is loaded)
|
|
10693
|
-
*/
|
|
10694
|
-
async ensureLayerGroup() {
|
|
10695
|
-
if (this.markerLayerGroup) {
|
|
10696
|
-
return;
|
|
10697
|
-
}
|
|
10698
|
-
const L3 = getLeaflet() || await loadLeaflet();
|
|
10699
|
-
this.markerLayerGroup = L3.layerGroup().addTo(this.map);
|
|
10668
|
+
this.markerLayerGroup = import_leaflet3.default.layerGroup().addTo(this.map);
|
|
10700
10669
|
}
|
|
10701
10670
|
/**
|
|
10702
10671
|
* Creates a new marker from coordinates
|
|
@@ -10719,7 +10688,7 @@ var MarkerManager = class {
|
|
|
10719
10688
|
* @throws {Error} If neither position nor imageCoords is provided
|
|
10720
10689
|
* @throws {Error} If coordinates are invalid or out of bounds
|
|
10721
10690
|
*/
|
|
10722
|
-
|
|
10691
|
+
createMarker(options) {
|
|
10723
10692
|
if (!options.position && !options.imageCoords) {
|
|
10724
10693
|
throw new Error("Either position or imageCoords must be provided");
|
|
10725
10694
|
}
|
|
@@ -10765,11 +10734,10 @@ var MarkerManager = class {
|
|
|
10765
10734
|
deletable: options.deletable
|
|
10766
10735
|
};
|
|
10767
10736
|
this.validateMarker(marker);
|
|
10768
|
-
const leafletMarker =
|
|
10737
|
+
const leafletMarker = this.createLeafletMarker(marker);
|
|
10769
10738
|
this.setupMarkerInteractions(leafletMarker, marker);
|
|
10770
10739
|
this.markers.set(id, marker);
|
|
10771
10740
|
this.leafletMarkers.set(id, leafletMarker);
|
|
10772
|
-
await this.ensureLayerGroup();
|
|
10773
10741
|
this.markerLayerGroup.addLayer(leafletMarker);
|
|
10774
10742
|
return marker;
|
|
10775
10743
|
}
|
|
@@ -10911,9 +10879,7 @@ var MarkerManager = class {
|
|
|
10911
10879
|
if (!marker || !leafletMarker) {
|
|
10912
10880
|
return false;
|
|
10913
10881
|
}
|
|
10914
|
-
|
|
10915
|
-
this.markerLayerGroup.removeLayer(leafletMarker);
|
|
10916
|
-
}
|
|
10882
|
+
this.markerLayerGroup.removeLayer(leafletMarker);
|
|
10917
10883
|
this.removeActiveMarkerOverlay(id);
|
|
10918
10884
|
if (this.activeMarkerId === id) {
|
|
10919
10885
|
this.setActiveMarker(null);
|
|
@@ -10926,9 +10892,7 @@ var MarkerManager = class {
|
|
|
10926
10892
|
* Removes all markers
|
|
10927
10893
|
*/
|
|
10928
10894
|
removeAllMarkers() {
|
|
10929
|
-
|
|
10930
|
-
this.markerLayerGroup.clearLayers();
|
|
10931
|
-
}
|
|
10895
|
+
this.markerLayerGroup.clearLayers();
|
|
10932
10896
|
this.markers.clear();
|
|
10933
10897
|
this.leafletMarkers.clear();
|
|
10934
10898
|
this.activeMarkerOverlays.clear();
|
|
@@ -10973,7 +10937,7 @@ var MarkerManager = class {
|
|
|
10973
10937
|
* @param updates - Partial marker properties to update
|
|
10974
10938
|
* @returns True if marker was updated, false if not found
|
|
10975
10939
|
*/
|
|
10976
|
-
|
|
10940
|
+
updateMarker(id, updates) {
|
|
10977
10941
|
const marker = this.markers.get(id);
|
|
10978
10942
|
const leafletMarker = this.leafletMarkers.get(id);
|
|
10979
10943
|
if (!marker || !leafletMarker) {
|
|
@@ -10996,7 +10960,7 @@ var MarkerManager = class {
|
|
|
10996
10960
|
}
|
|
10997
10961
|
if (updates.iconType !== void 0) {
|
|
10998
10962
|
marker.iconType = updates.iconType;
|
|
10999
|
-
const newIcon =
|
|
10963
|
+
const newIcon = this.createCustomIcon(updates.iconType);
|
|
11000
10964
|
leafletMarker.setIcon(newIcon);
|
|
11001
10965
|
}
|
|
11002
10966
|
if (updates.referenceId !== void 0) {
|
|
@@ -11154,7 +11118,7 @@ var MarkerManager = class {
|
|
|
11154
11118
|
* @param id - Marker ID to set as active, or null to clear active marker
|
|
11155
11119
|
* @returns True if marker was set as active, false if not found
|
|
11156
11120
|
*/
|
|
11157
|
-
|
|
11121
|
+
setActiveMarker(id) {
|
|
11158
11122
|
if (id === null) {
|
|
11159
11123
|
const previousActiveId = this.activeMarkerId;
|
|
11160
11124
|
this.activeMarkerId = null;
|
|
@@ -11186,9 +11150,7 @@ var MarkerManager = class {
|
|
|
11186
11150
|
leafletMarker.closePopup();
|
|
11187
11151
|
}
|
|
11188
11152
|
this.activeMarkerId = id;
|
|
11189
|
-
this.addActiveMarkerOverlay(id)
|
|
11190
|
-
console.warn("Failed to add active marker overlay:", error);
|
|
11191
|
-
});
|
|
11153
|
+
this.addActiveMarkerOverlay(id);
|
|
11192
11154
|
if (this.interactionConfig.onActiveMarkerChange) {
|
|
11193
11155
|
this.interactionConfig.onActiveMarkerChange(marker);
|
|
11194
11156
|
}
|
|
@@ -11313,14 +11275,14 @@ var MarkerManager = class {
|
|
|
11313
11275
|
* @param iconType - New icon type
|
|
11314
11276
|
* @returns True if marker was updated, false if not found
|
|
11315
11277
|
*/
|
|
11316
|
-
|
|
11278
|
+
updateMarkerIcon(id, iconType) {
|
|
11317
11279
|
const marker = this.markers.get(id);
|
|
11318
11280
|
const leafletMarker = this.leafletMarkers.get(id);
|
|
11319
11281
|
if (!marker || !leafletMarker) {
|
|
11320
11282
|
return false;
|
|
11321
11283
|
}
|
|
11322
11284
|
marker.iconType = iconType;
|
|
11323
|
-
const newIcon =
|
|
11285
|
+
const newIcon = this.createCustomIcon(iconType);
|
|
11324
11286
|
leafletMarker.setIcon(newIcon);
|
|
11325
11287
|
return true;
|
|
11326
11288
|
}
|
|
@@ -11334,6 +11296,65 @@ var MarkerManager = class {
|
|
|
11334
11296
|
this.updateMarkerIcon(id, iconType);
|
|
11335
11297
|
});
|
|
11336
11298
|
}
|
|
11299
|
+
/**
|
|
11300
|
+
* Focuses on a marker by panning and zooming to its position
|
|
11301
|
+
*
|
|
11302
|
+
* This method smoothly animates the map view to center on the specified marker
|
|
11303
|
+
* and optionally sets a specific zoom level. If no zoom level is provided,
|
|
11304
|
+
* it uses the marker's saved zoom level or a reasonable default.
|
|
11305
|
+
*
|
|
11306
|
+
* @param markerOrId - Marker ID string or Marker object
|
|
11307
|
+
* @param options - Optional focus options
|
|
11308
|
+
* @param options.zoom - Target zoom level (uses marker's zoom or default if not provided)
|
|
11309
|
+
* @param options.animate - Whether to animate the transition (default: true)
|
|
11310
|
+
* @param options.duration - Animation duration in seconds (default: 0.5)
|
|
11311
|
+
* @returns True if focus was successful, false if marker not found
|
|
11312
|
+
*
|
|
11313
|
+
* @example
|
|
11314
|
+
* ```typescript
|
|
11315
|
+
* // Focus on marker by ID
|
|
11316
|
+
* markerManager.focusMarker('marker-123');
|
|
11317
|
+
*
|
|
11318
|
+
* // Focus with specific zoom level
|
|
11319
|
+
* markerManager.focusMarker('marker-123', { zoom: 3 });
|
|
11320
|
+
*
|
|
11321
|
+
* // Focus without animation
|
|
11322
|
+
* markerManager.focusMarker('marker-123', { animate: false });
|
|
11323
|
+
*
|
|
11324
|
+
* // Focus with custom duration
|
|
11325
|
+
* markerManager.focusMarker('marker-123', { zoom: 2, duration: 1.0 });
|
|
11326
|
+
* ```
|
|
11327
|
+
*/
|
|
11328
|
+
focusMarker(markerOrId, options) {
|
|
11329
|
+
let marker = null;
|
|
11330
|
+
if (typeof markerOrId === "string") {
|
|
11331
|
+
marker = this.getMarker(markerOrId);
|
|
11332
|
+
} else {
|
|
11333
|
+
marker = markerOrId;
|
|
11334
|
+
}
|
|
11335
|
+
if (!marker) {
|
|
11336
|
+
console.warn(`Marker not found: ${markerOrId}`);
|
|
11337
|
+
return false;
|
|
11338
|
+
}
|
|
11339
|
+
const targetZoom = options?.zoom ?? marker.zoom ?? 2;
|
|
11340
|
+
const minZoom = this.imageInfo.minZoom ?? 0;
|
|
11341
|
+
const maxZoom = this.imageInfo.maxZoom ?? 5;
|
|
11342
|
+
const constrainedZoom = Math.max(minZoom, Math.min(maxZoom, targetZoom));
|
|
11343
|
+
const position = [
|
|
11344
|
+
marker.position[0],
|
|
11345
|
+
marker.position[1]
|
|
11346
|
+
];
|
|
11347
|
+
const animate = options?.animate !== false;
|
|
11348
|
+
const duration = options?.duration ?? 0.5;
|
|
11349
|
+
if (animate) {
|
|
11350
|
+
this.map.flyTo(position, constrainedZoom, {
|
|
11351
|
+
duration
|
|
11352
|
+
});
|
|
11353
|
+
} else {
|
|
11354
|
+
this.map.setView(position, constrainedZoom);
|
|
11355
|
+
}
|
|
11356
|
+
return true;
|
|
11357
|
+
}
|
|
11337
11358
|
/**
|
|
11338
11359
|
* Disposes of the marker manager and cleans up resources
|
|
11339
11360
|
*
|
|
@@ -11352,15 +11373,13 @@ var MarkerManager = class {
|
|
|
11352
11373
|
* @param iconType - Icon type to use
|
|
11353
11374
|
* @returns Leaflet icon instance
|
|
11354
11375
|
*/
|
|
11355
|
-
|
|
11356
|
-
const L3 = getLeaflet() || await loadLeaflet();
|
|
11376
|
+
createCustomIcon(iconType) {
|
|
11357
11377
|
const iconUrl = `${this.iconBasePath}${iconType}.png`;
|
|
11358
|
-
return
|
|
11378
|
+
return import_leaflet3.default.icon({
|
|
11359
11379
|
iconUrl,
|
|
11360
|
-
iconSize: [
|
|
11361
|
-
|
|
11362
|
-
|
|
11363
|
-
// Point of the icon which will correspond to marker's location
|
|
11380
|
+
iconSize: [MARKER_SPEC.WIDTH, MARKER_SPEC.HEIGHT],
|
|
11381
|
+
iconAnchor: [MARKER_SPEC.ANCHOR_X, MARKER_SPEC.ANCHOR_Y],
|
|
11382
|
+
// Anchor point aligns with marker location
|
|
11364
11383
|
popupAnchor: [0, 0],
|
|
11365
11384
|
// Point from which the popup should open relative to the iconAnchor
|
|
11366
11385
|
shadowUrl: void 0,
|
|
@@ -11375,11 +11394,9 @@ var MarkerManager = class {
|
|
|
11375
11394
|
* @param marker - Marker data
|
|
11376
11395
|
* @returns Leaflet marker instance
|
|
11377
11396
|
*/
|
|
11378
|
-
|
|
11379
|
-
const L3 = getLeaflet() || await loadLeaflet();
|
|
11380
|
-
await this.ensureLayerGroup();
|
|
11397
|
+
createLeafletMarker(marker) {
|
|
11381
11398
|
const iconType = marker.iconType || "pin-gray";
|
|
11382
|
-
const customIcon =
|
|
11399
|
+
const customIcon = this.createCustomIcon(iconType);
|
|
11383
11400
|
const markerOptions = {
|
|
11384
11401
|
title: marker.label,
|
|
11385
11402
|
icon: customIcon
|
|
@@ -11388,7 +11405,7 @@ var MarkerManager = class {
|
|
|
11388
11405
|
if (isDraggable) {
|
|
11389
11406
|
markerOptions.draggable = true;
|
|
11390
11407
|
}
|
|
11391
|
-
const leafletMarker =
|
|
11408
|
+
const leafletMarker = import_leaflet3.default.marker(
|
|
11392
11409
|
[marker.position[0], marker.position[1]],
|
|
11393
11410
|
markerOptions
|
|
11394
11411
|
);
|
|
@@ -11483,18 +11500,17 @@ var MarkerManager = class {
|
|
|
11483
11500
|
*
|
|
11484
11501
|
* @param id - Marker ID
|
|
11485
11502
|
*/
|
|
11486
|
-
|
|
11503
|
+
addActiveMarkerOverlay(id) {
|
|
11487
11504
|
this.removeActiveMarkerOverlay(id);
|
|
11488
11505
|
const marker = this.markers.get(id);
|
|
11489
11506
|
const leafletMarker = this.leafletMarkers.get(id);
|
|
11490
11507
|
if (!marker || !leafletMarker) {
|
|
11491
11508
|
return;
|
|
11492
11509
|
}
|
|
11493
|
-
await this.ensureLayerGroup();
|
|
11494
11510
|
const overlaySize = 40;
|
|
11495
11511
|
const borderWidth = 1;
|
|
11496
|
-
const overlayAnchorX =
|
|
11497
|
-
const overlayAnchorY =
|
|
11512
|
+
const overlayAnchorX = overlaySize / 2 + (MARKER_SPEC.WIDTH / 2 - MARKER_SPEC.ANCHOR_X);
|
|
11513
|
+
const overlayAnchorY = overlaySize / 2 + (MARKER_SPEC.HEIGHT / 2 - MARKER_SPEC.ANCHOR_Y);
|
|
11498
11514
|
const overlayHTML = `
|
|
11499
11515
|
<div style="
|
|
11500
11516
|
width: ${overlaySize}px;
|
|
@@ -11506,9 +11522,8 @@ var MarkerManager = class {
|
|
|
11506
11522
|
position: relative;
|
|
11507
11523
|
"></div>
|
|
11508
11524
|
`;
|
|
11509
|
-
const
|
|
11510
|
-
|
|
11511
|
-
icon: L3.divIcon({
|
|
11525
|
+
const overlay = import_leaflet3.default.marker([marker.position[0], marker.position[1]], {
|
|
11526
|
+
icon: import_leaflet3.default.divIcon({
|
|
11512
11527
|
html: overlayHTML,
|
|
11513
11528
|
className: "edgepdf-active-marker-overlay",
|
|
11514
11529
|
iconSize: [overlaySize, overlaySize],
|
|
@@ -11520,9 +11535,7 @@ var MarkerManager = class {
|
|
|
11520
11535
|
// Below marker but visible
|
|
11521
11536
|
});
|
|
11522
11537
|
this.activeMarkerOverlays.set(id, overlay);
|
|
11523
|
-
|
|
11524
|
-
this.markerLayerGroup.addLayer(overlay);
|
|
11525
|
-
}
|
|
11538
|
+
this.markerLayerGroup.addLayer(overlay);
|
|
11526
11539
|
leafletMarker.on("drag", () => {
|
|
11527
11540
|
const newPos = leafletMarker.getLatLng();
|
|
11528
11541
|
overlay.setLatLng(newPos);
|
|
@@ -11535,7 +11548,7 @@ var MarkerManager = class {
|
|
|
11535
11548
|
*/
|
|
11536
11549
|
removeActiveMarkerOverlay(id) {
|
|
11537
11550
|
const overlay = this.activeMarkerOverlays.get(id);
|
|
11538
|
-
if (overlay
|
|
11551
|
+
if (overlay) {
|
|
11539
11552
|
this.markerLayerGroup.removeLayer(overlay);
|
|
11540
11553
|
this.activeMarkerOverlays.delete(id);
|
|
11541
11554
|
}
|
|
@@ -11576,9 +11589,6 @@ var MarkerManager = class {
|
|
|
11576
11589
|
escapeHtml(text) {
|
|
11577
11590
|
if (!text)
|
|
11578
11591
|
return "";
|
|
11579
|
-
if (typeof document === "undefined") {
|
|
11580
|
-
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
11581
|
-
}
|
|
11582
11592
|
const div = document.createElement("div");
|
|
11583
11593
|
div.textContent = text;
|
|
11584
11594
|
return div.innerHTML;
|
|
@@ -11976,11 +11986,6 @@ function createZoomOutIconSVG() {
|
|
|
11976
11986
|
|
|
11977
11987
|
// packages/viewer-js/src/lib/marker-action-controls.ts
|
|
11978
11988
|
function createMarkerActionControls(container, markerManager) {
|
|
11979
|
-
if (typeof document === "undefined") {
|
|
11980
|
-
throw new Error(
|
|
11981
|
-
"createMarkerActionControls requires a browser environment (document is not available)"
|
|
11982
|
-
);
|
|
11983
|
-
}
|
|
11984
11989
|
const controlsDiv = document.createElement("div");
|
|
11985
11990
|
controlsDiv.className = "edgepdf-marker-action-controls";
|
|
11986
11991
|
controlsDiv.setAttribute("role", "group");
|
|
@@ -12094,11 +12099,6 @@ function createMarkerActionControls(container, markerManager) {
|
|
|
12094
12099
|
|
|
12095
12100
|
// packages/viewer-js/src/lib/zoom-controls.ts
|
|
12096
12101
|
function createZoomControls(container, zoomController, options) {
|
|
12097
|
-
if (typeof document === "undefined") {
|
|
12098
|
-
throw new Error(
|
|
12099
|
-
"createZoomControls requires a browser environment (document is not available)"
|
|
12100
|
-
);
|
|
12101
|
-
}
|
|
12102
12102
|
const position = options?.position ?? "top-right";
|
|
12103
12103
|
const existingControls = container.querySelector(
|
|
12104
12104
|
".edgepdf-zoom-controls"
|
|
@@ -12286,7 +12286,7 @@ var EdgePdfViewer = class {
|
|
|
12286
12286
|
*
|
|
12287
12287
|
* @throws {Error} If map initialization fails
|
|
12288
12288
|
*/
|
|
12289
|
-
|
|
12289
|
+
initialize() {
|
|
12290
12290
|
if (this.map) {
|
|
12291
12291
|
console.warn(
|
|
12292
12292
|
"Map already initialized. Call dispose() before reinitializing."
|
|
@@ -12294,10 +12294,9 @@ var EdgePdfViewer = class {
|
|
|
12294
12294
|
return;
|
|
12295
12295
|
}
|
|
12296
12296
|
try {
|
|
12297
|
-
const Leaflet = await loadLeaflet();
|
|
12298
12297
|
this.coordinateMapper = new CoordinateMapper(this.config.imageInfo);
|
|
12299
|
-
const customCRS =
|
|
12300
|
-
const bounds =
|
|
12298
|
+
const customCRS = this.coordinateMapper.createCustomCRS();
|
|
12299
|
+
const bounds = this.coordinateMapper.calculateMapBounds();
|
|
12301
12300
|
const imageCenter = this.coordinateMapper.getImageCenter();
|
|
12302
12301
|
const center = this.mapOptions?.center || [
|
|
12303
12302
|
imageCenter.y,
|
|
@@ -12325,11 +12324,11 @@ var EdgePdfViewer = class {
|
|
|
12325
12324
|
// Mouse wheel sensitivity
|
|
12326
12325
|
...this.mapOptions
|
|
12327
12326
|
};
|
|
12328
|
-
this.map =
|
|
12327
|
+
this.map = import_leaflet4.default.map(this.container, leafletOptions);
|
|
12329
12328
|
if (!this.mapOptions?.center && !this.mapOptions?.zoom) {
|
|
12330
12329
|
this.map.setView([imageCenter.y, imageCenter.x], initialZoom);
|
|
12331
12330
|
}
|
|
12332
|
-
|
|
12331
|
+
this.addTileLayer();
|
|
12333
12332
|
this.addSeamlessTileStyles();
|
|
12334
12333
|
this.zoomController = new ZoomController({
|
|
12335
12334
|
map: this.map,
|
|
@@ -12423,7 +12422,7 @@ var EdgePdfViewer = class {
|
|
|
12423
12422
|
*
|
|
12424
12423
|
* @throws {Error} If map is not initialized or tile layer creation fails
|
|
12425
12424
|
*/
|
|
12426
|
-
|
|
12425
|
+
addTileLayer() {
|
|
12427
12426
|
if (!this.map) {
|
|
12428
12427
|
throw new Error("Map must be initialized before adding tile layer");
|
|
12429
12428
|
}
|
|
@@ -12432,7 +12431,7 @@ var EdgePdfViewer = class {
|
|
|
12432
12431
|
tileUrl: this.config.tileUrl,
|
|
12433
12432
|
imageInfo: this.config.imageInfo
|
|
12434
12433
|
});
|
|
12435
|
-
const tileLayer =
|
|
12434
|
+
const tileLayer = this.tileLayerManager.createTileLayer(this.map);
|
|
12436
12435
|
tileLayer.addTo(this.map);
|
|
12437
12436
|
console.log("Tile layer added to map successfully");
|
|
12438
12437
|
} catch (error) {
|
|
@@ -12472,6 +12471,34 @@ var EdgePdfViewer = class {
|
|
|
12472
12471
|
getMarkerManager() {
|
|
12473
12472
|
return this.markerManager;
|
|
12474
12473
|
}
|
|
12474
|
+
/**
|
|
12475
|
+
* Focuses on a marker by panning and zooming to its position
|
|
12476
|
+
*
|
|
12477
|
+
* This is a convenience method that delegates to the marker manager's focusMarker method.
|
|
12478
|
+
*
|
|
12479
|
+
* @param markerOrId - Marker ID string or Marker object
|
|
12480
|
+
* @param options - Optional focus options
|
|
12481
|
+
* @param options.zoom - Target zoom level (uses marker's zoom or default if not provided)
|
|
12482
|
+
* @param options.animate - Whether to animate the transition (default: true)
|
|
12483
|
+
* @param options.duration - Animation duration in seconds (default: 0.5)
|
|
12484
|
+
* @returns True if focus was successful, false if marker not found or viewer not initialized
|
|
12485
|
+
*
|
|
12486
|
+
* @example
|
|
12487
|
+
* ```typescript
|
|
12488
|
+
* // Focus on marker by ID
|
|
12489
|
+
* viewer.focusMarker('marker-123');
|
|
12490
|
+
*
|
|
12491
|
+
* // Focus with specific zoom level
|
|
12492
|
+
* viewer.focusMarker('marker-123', { zoom: 3 });
|
|
12493
|
+
* ```
|
|
12494
|
+
*/
|
|
12495
|
+
focusMarker(markerOrId, options) {
|
|
12496
|
+
if (!this.markerManager) {
|
|
12497
|
+
console.warn("Marker manager not available");
|
|
12498
|
+
return false;
|
|
12499
|
+
}
|
|
12500
|
+
return this.markerManager.focusMarker(markerOrId, options);
|
|
12501
|
+
}
|
|
12475
12502
|
/**
|
|
12476
12503
|
* Disposes of the map instance and cleans up resources
|
|
12477
12504
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import L from 'leaflet';
|
|
2
2
|
import type { ImageInfo, LeafletCoords, ImageCoords, CoordinateBounds } from '@edgepdf/types';
|
|
3
3
|
/**
|
|
4
4
|
* Image position information within the tile grid canvas
|
|
@@ -124,7 +124,7 @@ export declare class CoordinateMapper {
|
|
|
124
124
|
* // [[0, 0], [512, 512]] for minZoom 0 with tileSize 256
|
|
125
125
|
* ```
|
|
126
126
|
*/
|
|
127
|
-
calculateMapBounds():
|
|
127
|
+
calculateMapBounds(): L.LatLngBoundsExpression;
|
|
128
128
|
/**
|
|
129
129
|
* Validates Leaflet coordinates and checks bounds
|
|
130
130
|
*
|
|
@@ -145,7 +145,7 @@ export declare class CoordinateMapper {
|
|
|
145
145
|
*
|
|
146
146
|
* @returns Custom CRS instance
|
|
147
147
|
*/
|
|
148
|
-
createCustomCRS():
|
|
148
|
+
createCustomCRS(): L.CRS;
|
|
149
149
|
/**
|
|
150
150
|
* Calculates the aspect ratio of the image
|
|
151
151
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coordinate-mapper.d.ts","sourceRoot":"","sources":["../../src/lib/coordinate-mapper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"coordinate-mapper.d.ts","sourceRoot":"","sources":["../../src/lib/coordinate-mapper.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,SAAS,CAAC;AACxB,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EACb,WAAW,EACX,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AAExB;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,oDAAoD;IACpD,gBAAgB,EAAE,MAAM,CAAC;IACzB,qDAAqD;IACrD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,sCAAsC;IACtC,YAAY,EAAE,MAAM,CAAC;IACrB,sCAAsC;IACtC,YAAY,EAAE,MAAM,CAAC;IACrB,yBAAyB;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,0BAA0B;IAC1B,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,SAAS,CAAY;IAE7B;;;;;;OAMG;gBACS,SAAS,EAAE,SAAS;IAchC;;;;;OAKG;IACH,sBAAsB,IAAI,aAAa;IAuCvC;;;;;;;;;;;;;OAaG;IACH,cAAc,CACZ,aAAa,EAAE,aAAa,GAC3B,WAAW,GAAG;QAAE,YAAY,EAAE,OAAO,CAAA;KAAE;IAyB1C;;;;;;;;;;;;;OAaG;IACH,cAAc,CAAC,WAAW,EAAE,WAAW,GAAG,aAAa;IAkBvD;;;;;;;;;;OAUG;IACH,cAAc,IAAI;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE;IAU1C;;;;;;;;;;;;;OAaG;IACH,kBAAkB,IAAI,CAAC,CAAC,sBAAsB;IAU9C;;;;;OAKG;IACH,qBAAqB,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI;IAqBlD;;;;;OAKG;IACH,mBAAmB,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;IA+B9C;;;;;OAKG;IACH,eAAe,IAAI,CAAC,CAAC,GAAG;IAMxB;;;;;;;;;;OAUG;IACH,cAAc,IAAI,MAAM;IAIxB;;;;;;;;;;OAUG;IACH,SAAS,IAAI,gBAAgB;IAS7B;;;;OAIG;IACH,YAAY,IAAI,SAAS;IAIzB;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO;IAS5C;;;;;;;;;;;;;OAaG;IACH,aAAa,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW;IAO/C;;;;;;;;;;;;;;;;;;;OAmBG;IACH,qBAAqB,CACnB,MAAM,EAAE,WAAW,EACnB,cAAc,EAAE,MAAM,EACtB,eAAe,EAAE,MAAM,GACtB,WAAW;CAaf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marker-action-controls.d.ts","sourceRoot":"","sources":["../../src/lib/marker-action-controls.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGzD;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,WAAW,EACtB,aAAa,EAAE,aAAa,GAC3B,WAAW,
|
|
1
|
+
{"version":3,"file":"marker-action-controls.d.ts","sourceRoot":"","sources":["../../src/lib/marker-action-controls.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGzD;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,WAAW,EACtB,aAAa,EAAE,aAAa,GAC3B,WAAW,CAoJb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marker-delete-popup.d.ts","sourceRoot":"","sources":["../../src/lib/marker-delete-popup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,sCAAsC;IACtC,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAOD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,WAAW,
|
|
1
|
+
{"version":3,"file":"marker-delete-popup.d.ts","sourceRoot":"","sources":["../../src/lib/marker-delete-popup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,sCAAsC;IACtC,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAOD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,WAAW,CAgH1E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marker-edit-popup.d.ts","sourceRoot":"","sources":["../../src/lib/marker-edit-popup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,oCAAoC;IACpC,MAAM,EAAE,CAAC,OAAO,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAC7D,sCAAsC;IACtC,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAOD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,WAAW,
|
|
1
|
+
{"version":3,"file":"marker-edit-popup.d.ts","sourceRoot":"","sources":["../../src/lib/marker-edit-popup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,oCAAoC;IACpC,MAAM,EAAE,CAAC,OAAO,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAC7D,sCAAsC;IACtC,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAOD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,WAAW,CAqJtE"}
|