@edgepdf/viewer-js 0.0.2 → 0.0.4
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 +76 -24
- package/dist/images/pin-gray-selected.png +0 -0
- package/dist/images/pin-gray.png +0 -0
- package/dist/images/pin-yellow-selected.png +0 -0
- package/dist/images/pin-yellow.png +0 -0
- package/dist/images/pin.png +0 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +162 -10
- package/dist/lib/marker-manager.d.ts +61 -0
- package/dist/lib/marker-manager.d.ts.map +1 -1
- package/dist/styles.d.ts +10 -0
- package/dist/styles.d.ts.map +1 -0
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -10,11 +10,7 @@ npm install @edgepdf/viewer-js
|
|
|
10
10
|
pnpm add @edgepdf/viewer-js
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
**Note:** Leaflet is bundled with this library, so you don't need to install it separately.
|
|
14
|
-
|
|
15
|
-
```typescript
|
|
16
|
-
import '@edgepdf/viewer-js/styles.css';
|
|
17
|
-
```
|
|
13
|
+
**Note:** Leaflet is bundled with this library, so you don't need to install it separately. **CSS styles are automatically injected** when you import the library - no manual CSS import needed!
|
|
18
14
|
|
|
19
15
|
## Usage
|
|
20
16
|
|
|
@@ -22,8 +18,8 @@ import '@edgepdf/viewer-js/styles.css';
|
|
|
22
18
|
|
|
23
19
|
```typescript
|
|
24
20
|
import { EdgePdfViewer } from '@edgepdf/viewer-js';
|
|
25
|
-
import '@edgepdf/viewer-js/styles.css'; // Required: Leaflet CSS
|
|
26
21
|
import type { ViewerConfig } from '@edgepdf/types';
|
|
22
|
+
// CSS is automatically injected - no need to import styles manually!
|
|
27
23
|
|
|
28
24
|
// Get container element
|
|
29
25
|
const container = document.getElementById('map-container');
|
|
@@ -36,8 +32,8 @@ const config: ViewerConfig = {
|
|
|
36
32
|
height: 3000,
|
|
37
33
|
tileSize: 256,
|
|
38
34
|
maxZoom: 5,
|
|
39
|
-
minZoom: 0
|
|
40
|
-
}
|
|
35
|
+
minZoom: 0,
|
|
36
|
+
},
|
|
41
37
|
};
|
|
42
38
|
|
|
43
39
|
// Create and initialize viewer
|
|
@@ -52,8 +48,8 @@ viewer.dispose();
|
|
|
52
48
|
|
|
53
49
|
```typescript
|
|
54
50
|
import { EdgePdfViewer } from '@edgepdf/viewer-js';
|
|
55
|
-
import '@edgepdf/viewer-js/styles.css'; // Required: Leaflet CSS
|
|
56
51
|
import type { ViewerConfig, MapOptions } from '@edgepdf/types';
|
|
52
|
+
// CSS is automatically injected - no need to import styles manually!
|
|
57
53
|
|
|
58
54
|
const config: ViewerConfig = {
|
|
59
55
|
tileUrl: 'https://example.com/tiles/{z}/{x}/{y}.png',
|
|
@@ -62,21 +58,21 @@ const config: ViewerConfig = {
|
|
|
62
58
|
height: 3000,
|
|
63
59
|
tileSize: 256,
|
|
64
60
|
maxZoom: 5,
|
|
65
|
-
minZoom: 0
|
|
66
|
-
}
|
|
61
|
+
minZoom: 0,
|
|
62
|
+
},
|
|
67
63
|
};
|
|
68
64
|
|
|
69
65
|
const mapOptions: MapOptions = {
|
|
70
66
|
center: [1500, 1000], // [y, x] in pixel coordinates
|
|
71
67
|
zoom: 2,
|
|
72
68
|
minZoom: 0,
|
|
73
|
-
maxZoom: 5
|
|
69
|
+
maxZoom: 5,
|
|
74
70
|
};
|
|
75
71
|
|
|
76
72
|
const viewer = new EdgePdfViewer({
|
|
77
73
|
container: document.getElementById('map-container'),
|
|
78
74
|
config,
|
|
79
|
-
mapOptions
|
|
75
|
+
mapOptions,
|
|
80
76
|
});
|
|
81
77
|
|
|
82
78
|
viewer.initialize();
|
|
@@ -99,11 +95,13 @@ new EdgePdfViewer(options: {
|
|
|
99
95
|
```
|
|
100
96
|
|
|
101
97
|
**Parameters:**
|
|
98
|
+
|
|
102
99
|
- `container` - HTML element that will contain the map
|
|
103
100
|
- `config` - Viewer configuration with tile URL and image info
|
|
104
101
|
- `mapOptions` - Optional Leaflet map options (center, zoom, etc.)
|
|
105
102
|
|
|
106
103
|
**Throws:**
|
|
104
|
+
|
|
107
105
|
- `Error` if container is not provided or invalid
|
|
108
106
|
- `Error` if config is not provided or invalid
|
|
109
107
|
- `Error` if tileUrl is missing
|
|
@@ -116,6 +114,7 @@ new EdgePdfViewer(options: {
|
|
|
116
114
|
Initializes the Leaflet map with custom CRS (Coordinate Reference System). Sets up a custom CRS.Simple coordinate system suitable for displaying image tiles without geographic coordinates.
|
|
117
115
|
|
|
118
116
|
**Throws:**
|
|
117
|
+
|
|
119
118
|
- `Error` if map initialization fails
|
|
120
119
|
|
|
121
120
|
##### `getMap(): L.Map | null`
|
|
@@ -140,9 +139,9 @@ Disposes of the map instance and cleans up resources. This should be called when
|
|
|
140
139
|
|
|
141
140
|
```typescript
|
|
142
141
|
interface ViewerConfig {
|
|
143
|
-
tileUrl: string;
|
|
144
|
-
imageInfo: ImageInfo;
|
|
145
|
-
onPinsUpdate?: (pins: Marker[]) => void;
|
|
142
|
+
tileUrl: string; // Tile URL template with {z}, {x}, {y} placeholders
|
|
143
|
+
imageInfo: ImageInfo; // Image metadata
|
|
144
|
+
onPinsUpdate?: (pins: Marker[]) => void; // Optional callback for marker updates
|
|
146
145
|
originalImagePath?: string; // Optional original image path
|
|
147
146
|
}
|
|
148
147
|
```
|
|
@@ -151,11 +150,11 @@ interface ViewerConfig {
|
|
|
151
150
|
|
|
152
151
|
```typescript
|
|
153
152
|
interface ImageInfo {
|
|
154
|
-
width: number;
|
|
155
|
-
height: number;
|
|
153
|
+
width: number; // Original image width in pixels
|
|
154
|
+
height: number; // Original image height in pixels
|
|
156
155
|
tileSize: number; // Tile size in pixels (default: 256)
|
|
157
|
-
maxZoom: number;
|
|
158
|
-
minZoom: number;
|
|
156
|
+
maxZoom: number; // Maximum zoom level
|
|
157
|
+
minZoom: number; // Minimum zoom level
|
|
159
158
|
}
|
|
160
159
|
```
|
|
161
160
|
|
|
@@ -163,10 +162,10 @@ interface ImageInfo {
|
|
|
163
162
|
|
|
164
163
|
```typescript
|
|
165
164
|
interface MapOptions {
|
|
166
|
-
center?: [number, number];
|
|
167
|
-
zoom?: number;
|
|
168
|
-
minZoom?: number;
|
|
169
|
-
maxZoom?: number;
|
|
165
|
+
center?: [number, number]; // Initial center coordinates [y, x]
|
|
166
|
+
zoom?: number; // Initial zoom level
|
|
167
|
+
minZoom?: number; // Minimum zoom level
|
|
168
|
+
maxZoom?: number; // Maximum zoom level
|
|
170
169
|
bounds?: {
|
|
171
170
|
southwest: [number, number];
|
|
172
171
|
northeast: [number, number];
|
|
@@ -174,6 +173,59 @@ interface MapOptions {
|
|
|
174
173
|
}
|
|
175
174
|
```
|
|
176
175
|
|
|
176
|
+
## Marker Icons
|
|
177
|
+
|
|
178
|
+
The library includes built-in pin icons that are automatically available in the `dist/images/` folder:
|
|
179
|
+
|
|
180
|
+
- `pin.png` - Default pin icon
|
|
181
|
+
- `pin-gray.png` - Gray pin icon
|
|
182
|
+
- `pin-yellow.png` - Yellow pin icon
|
|
183
|
+
- `pin-gray-selected.png` - Gray pin (selected state)
|
|
184
|
+
- `pin-yellow-selected.png` - Yellow pin (selected state)
|
|
185
|
+
|
|
186
|
+
### Using Built-in Icons
|
|
187
|
+
|
|
188
|
+
By default, the `MarkerManager` uses `./images/` as the icon base path. To use the built-in icons:
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
const viewer = new EdgePdfViewer({ container, config });
|
|
192
|
+
viewer.initialize();
|
|
193
|
+
|
|
194
|
+
const markerManager = viewer.getMarkerManager();
|
|
195
|
+
// Icons are automatically loaded from the library's dist/images/ folder
|
|
196
|
+
// No configuration needed if serving from the library location
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Customizing Icons
|
|
200
|
+
|
|
201
|
+
To use custom icons, copy the icon files from `node_modules/@edgepdf/viewer-js/dist/images/` to your public folder, customize them, and set the icon base path:
|
|
202
|
+
|
|
203
|
+
```typescript
|
|
204
|
+
const markerManager = viewer.getMarkerManager();
|
|
205
|
+
|
|
206
|
+
// Option 1: Serve from your public folder (recommended for customization)
|
|
207
|
+
markerManager.setIconBasePath('/'); // Icons in public/ folder
|
|
208
|
+
|
|
209
|
+
// Option 2: Use a CDN
|
|
210
|
+
markerManager.setIconBasePath('https://cdn.example.com/icons/');
|
|
211
|
+
|
|
212
|
+
// Option 3: Use relative path
|
|
213
|
+
markerManager.setIconBasePath('./assets/icons/');
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
**Note:** Icon files must be named exactly as listed above (e.g., `pin.png`, `pin-gray.png`, etc.) for the library to find them.
|
|
217
|
+
|
|
218
|
+
### Available Icon Types
|
|
219
|
+
|
|
220
|
+
```typescript
|
|
221
|
+
type IconType =
|
|
222
|
+
| 'pin'
|
|
223
|
+
| 'pin-gray'
|
|
224
|
+
| 'pin-yellow'
|
|
225
|
+
| 'pin-gray-selected'
|
|
226
|
+
| 'pin-yellow-selected';
|
|
227
|
+
```
|
|
228
|
+
|
|
177
229
|
## Coordinate System
|
|
178
230
|
|
|
179
231
|
The viewer uses Leaflet's `CRS.Simple` coordinate system, which treats coordinates as pixel positions rather than geographic lat/lng. This is ideal for displaying image tiles:
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
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,UAAU,CAAC;AAElB,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,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,YAAY,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAGnE,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,6 +9575,28 @@ var require_leaflet_src = __commonJS({
|
|
|
9575
9575
|
}
|
|
9576
9576
|
});
|
|
9577
9577
|
|
|
9578
|
+
// packages/viewer-js/src/styles.ts
|
|
9579
|
+
if (typeof window !== "undefined" && typeof document !== "undefined") {
|
|
9580
|
+
const existingLink = document.querySelector("link[data-edgepdf-styles]");
|
|
9581
|
+
if (!existingLink) {
|
|
9582
|
+
const link = document.createElement("link");
|
|
9583
|
+
link.rel = "stylesheet";
|
|
9584
|
+
link.type = "text/css";
|
|
9585
|
+
link.setAttribute("data-edgepdf-styles", "true");
|
|
9586
|
+
try {
|
|
9587
|
+
if (typeof import.meta !== "undefined" && import.meta.url) {
|
|
9588
|
+
const baseUrl = new URL(import.meta.url);
|
|
9589
|
+
link.href = new URL("./styles.css", baseUrl).href;
|
|
9590
|
+
} else {
|
|
9591
|
+
link.href = "./styles.css";
|
|
9592
|
+
}
|
|
9593
|
+
} catch (e) {
|
|
9594
|
+
link.href = "./styles.css";
|
|
9595
|
+
}
|
|
9596
|
+
document.head.appendChild(link);
|
|
9597
|
+
}
|
|
9598
|
+
}
|
|
9599
|
+
|
|
9578
9600
|
// packages/viewer-js/src/lib/viewer.ts
|
|
9579
9601
|
var import_leaflet4 = __toESM(require_leaflet_src(), 1);
|
|
9580
9602
|
|
|
@@ -10586,6 +10608,9 @@ var MarkerManager = class {
|
|
|
10586
10608
|
showEditButton: true,
|
|
10587
10609
|
showDeleteButton: true
|
|
10588
10610
|
};
|
|
10611
|
+
defaultIconType = "pin";
|
|
10612
|
+
iconBasePath = "./images/";
|
|
10613
|
+
// Default to library's images folder
|
|
10589
10614
|
/**
|
|
10590
10615
|
* Creates a new MarkerManager instance
|
|
10591
10616
|
*
|
|
@@ -10672,7 +10697,8 @@ var MarkerManager = class {
|
|
|
10672
10697
|
annotation: options.annotation,
|
|
10673
10698
|
href: options.href,
|
|
10674
10699
|
target: options.target,
|
|
10675
|
-
showLabel: options.showLabel ?? true
|
|
10700
|
+
showLabel: options.showLabel ?? true,
|
|
10701
|
+
iconType: options.iconType || this.defaultIconType
|
|
10676
10702
|
};
|
|
10677
10703
|
this.validateMarker(marker);
|
|
10678
10704
|
const leafletMarker = this.createLeafletMarker(marker);
|
|
@@ -11054,6 +11080,95 @@ var MarkerManager = class {
|
|
|
11054
11080
|
this.eventListeners.clear();
|
|
11055
11081
|
}
|
|
11056
11082
|
}
|
|
11083
|
+
/**
|
|
11084
|
+
* Sets the default icon type for new markers
|
|
11085
|
+
*
|
|
11086
|
+
* @param iconType - Icon type to use as default
|
|
11087
|
+
*/
|
|
11088
|
+
setDefaultIconType(iconType) {
|
|
11089
|
+
this.defaultIconType = iconType;
|
|
11090
|
+
}
|
|
11091
|
+
/**
|
|
11092
|
+
* Gets the current default icon type
|
|
11093
|
+
*
|
|
11094
|
+
* @returns Current default icon type
|
|
11095
|
+
*/
|
|
11096
|
+
getDefaultIconType() {
|
|
11097
|
+
return this.defaultIconType;
|
|
11098
|
+
}
|
|
11099
|
+
/**
|
|
11100
|
+
* Sets the base path for marker icons
|
|
11101
|
+
*
|
|
11102
|
+
* @param basePath - Base path for icon files (default: './images/')
|
|
11103
|
+
*
|
|
11104
|
+
* @example
|
|
11105
|
+
* ```typescript
|
|
11106
|
+
* // Use library's built-in icons (default)
|
|
11107
|
+
* markerManager.setIconBasePath('./images/');
|
|
11108
|
+
*
|
|
11109
|
+
* // Use custom icons from public folder
|
|
11110
|
+
* markerManager.setIconBasePath('/');
|
|
11111
|
+
*
|
|
11112
|
+
* // Use icons from a CDN
|
|
11113
|
+
* markerManager.setIconBasePath('https://cdn.example.com/icons/');
|
|
11114
|
+
* ```
|
|
11115
|
+
*/
|
|
11116
|
+
setIconBasePath(basePath) {
|
|
11117
|
+
this.iconBasePath = basePath.endsWith("/") ? basePath : `${basePath}/`;
|
|
11118
|
+
}
|
|
11119
|
+
/**
|
|
11120
|
+
* Gets the current base path for marker icons
|
|
11121
|
+
*
|
|
11122
|
+
* @returns The current icon base path
|
|
11123
|
+
*/
|
|
11124
|
+
getIconBasePath() {
|
|
11125
|
+
return this.iconBasePath;
|
|
11126
|
+
}
|
|
11127
|
+
/**
|
|
11128
|
+
* Updates the icon type for a specific marker
|
|
11129
|
+
*
|
|
11130
|
+
* @param id - Marker ID
|
|
11131
|
+
* @param iconType - New icon type
|
|
11132
|
+
* @returns True if marker was updated, false if not found
|
|
11133
|
+
*/
|
|
11134
|
+
updateMarkerIcon(id, iconType) {
|
|
11135
|
+
const marker = this.markers.get(id);
|
|
11136
|
+
const leafletMarker = this.leafletMarkers.get(id);
|
|
11137
|
+
if (!marker || !leafletMarker) {
|
|
11138
|
+
return false;
|
|
11139
|
+
}
|
|
11140
|
+
const isSelected = this.selectedIds.has(id);
|
|
11141
|
+
if (isSelected && (iconType === "pin-gray" || iconType === "pin-yellow" || iconType === "pin")) {
|
|
11142
|
+
if (iconType === "pin-gray" || iconType === "pin") {
|
|
11143
|
+
iconType = "pin-gray-selected";
|
|
11144
|
+
} else if (iconType === "pin-yellow") {
|
|
11145
|
+
iconType = "pin-yellow-selected";
|
|
11146
|
+
}
|
|
11147
|
+
}
|
|
11148
|
+
marker.iconType = iconType;
|
|
11149
|
+
const newIcon = this.createCustomIcon(iconType);
|
|
11150
|
+
leafletMarker.setIcon(newIcon);
|
|
11151
|
+
return true;
|
|
11152
|
+
}
|
|
11153
|
+
/**
|
|
11154
|
+
* Updates all markers to use a new icon type
|
|
11155
|
+
*
|
|
11156
|
+
* @param iconType - Icon type to apply to all markers
|
|
11157
|
+
*/
|
|
11158
|
+
updateAllMarkerIcons(iconType) {
|
|
11159
|
+
this.markers.forEach((marker, id) => {
|
|
11160
|
+
const isSelected = this.selectedIds.has(id);
|
|
11161
|
+
let finalIconType = iconType;
|
|
11162
|
+
if (isSelected) {
|
|
11163
|
+
if (iconType === "pin-gray" || iconType === "pin") {
|
|
11164
|
+
finalIconType = "pin-gray-selected";
|
|
11165
|
+
} else if (iconType === "pin-yellow") {
|
|
11166
|
+
finalIconType = "pin-yellow-selected";
|
|
11167
|
+
}
|
|
11168
|
+
}
|
|
11169
|
+
this.updateMarkerIcon(id, finalIconType);
|
|
11170
|
+
});
|
|
11171
|
+
}
|
|
11057
11172
|
/**
|
|
11058
11173
|
* Disposes of the marker manager and cleans up resources
|
|
11059
11174
|
*
|
|
@@ -11066,6 +11181,28 @@ var MarkerManager = class {
|
|
|
11066
11181
|
this.map.removeLayer(this.markerLayerGroup);
|
|
11067
11182
|
}
|
|
11068
11183
|
}
|
|
11184
|
+
/**
|
|
11185
|
+
* Creates a custom icon for a marker
|
|
11186
|
+
*
|
|
11187
|
+
* @param iconType - Icon type to use
|
|
11188
|
+
* @returns Leaflet icon instance
|
|
11189
|
+
*/
|
|
11190
|
+
createCustomIcon(iconType) {
|
|
11191
|
+
const iconUrl = `${this.iconBasePath}${iconType}.png`;
|
|
11192
|
+
return import_leaflet3.default.icon({
|
|
11193
|
+
iconUrl,
|
|
11194
|
+
iconSize: [30, 40],
|
|
11195
|
+
// Default marker size
|
|
11196
|
+
iconAnchor: [30, 10],
|
|
11197
|
+
// Point of the icon which will correspond to marker's location
|
|
11198
|
+
popupAnchor: [0, 0],
|
|
11199
|
+
// Point from which the popup should open relative to the iconAnchor
|
|
11200
|
+
shadowUrl: void 0,
|
|
11201
|
+
// No shadow
|
|
11202
|
+
shadowSize: void 0,
|
|
11203
|
+
shadowAnchor: void 0
|
|
11204
|
+
});
|
|
11205
|
+
}
|
|
11069
11206
|
/**
|
|
11070
11207
|
* Creates a Leaflet marker from marker data
|
|
11071
11208
|
*
|
|
@@ -11073,8 +11210,11 @@ var MarkerManager = class {
|
|
|
11073
11210
|
* @returns Leaflet marker instance
|
|
11074
11211
|
*/
|
|
11075
11212
|
createLeafletMarker(marker) {
|
|
11213
|
+
const iconType = marker.iconType || this.defaultIconType;
|
|
11214
|
+
const customIcon = this.createCustomIcon(iconType);
|
|
11076
11215
|
const markerOptions = {
|
|
11077
|
-
title: marker.title
|
|
11216
|
+
title: marker.title,
|
|
11217
|
+
icon: customIcon
|
|
11078
11218
|
};
|
|
11079
11219
|
if (this.interactionConfig.draggable) {
|
|
11080
11220
|
markerOptions.draggable = true;
|
|
@@ -11177,20 +11317,32 @@ var MarkerManager = class {
|
|
|
11177
11317
|
* @param selected - Whether marker is selected
|
|
11178
11318
|
*/
|
|
11179
11319
|
updateMarkerSelectionVisual(id, selected) {
|
|
11320
|
+
const marker = this.markers.get(id);
|
|
11180
11321
|
const leafletMarker = this.leafletMarkers.get(id);
|
|
11181
|
-
if (!leafletMarker) {
|
|
11322
|
+
if (!marker || !leafletMarker) {
|
|
11182
11323
|
return;
|
|
11183
11324
|
}
|
|
11184
|
-
|
|
11185
|
-
if (
|
|
11186
|
-
if (selected) {
|
|
11187
|
-
|
|
11188
|
-
|
|
11325
|
+
let newIconType;
|
|
11326
|
+
if (selected) {
|
|
11327
|
+
if (marker.iconType === "pin-gray" || marker.iconType === "pin-gray-selected") {
|
|
11328
|
+
newIconType = "pin-gray-selected";
|
|
11329
|
+
} else if (marker.iconType === "pin-yellow" || marker.iconType === "pin-yellow-selected") {
|
|
11330
|
+
newIconType = "pin-yellow-selected";
|
|
11331
|
+
} else {
|
|
11332
|
+
newIconType = "pin-gray-selected";
|
|
11333
|
+
}
|
|
11334
|
+
} else {
|
|
11335
|
+
if (marker.iconType === "pin-gray" || marker.iconType === "pin-gray-selected") {
|
|
11336
|
+
newIconType = "pin-gray";
|
|
11337
|
+
} else if (marker.iconType === "pin-yellow" || marker.iconType === "pin-yellow-selected") {
|
|
11338
|
+
newIconType = "pin-yellow";
|
|
11189
11339
|
} else {
|
|
11190
|
-
|
|
11191
|
-
iconElement.style.zIndex = "";
|
|
11340
|
+
newIconType = marker.iconType || this.defaultIconType;
|
|
11192
11341
|
}
|
|
11193
11342
|
}
|
|
11343
|
+
marker.iconType = newIconType;
|
|
11344
|
+
const newIcon = this.createCustomIcon(newIconType);
|
|
11345
|
+
leafletMarker.setIcon(newIcon);
|
|
11194
11346
|
}
|
|
11195
11347
|
/**
|
|
11196
11348
|
* Emits an event to all registered listeners
|
|
@@ -21,6 +21,8 @@ export interface CreateMarkerOptions {
|
|
|
21
21
|
showLabel?: boolean;
|
|
22
22
|
/** Custom marker ID (auto-generated if not provided) */
|
|
23
23
|
id?: string;
|
|
24
|
+
/** Icon type for the marker */
|
|
25
|
+
iconType?: 'pin' | 'pin-gray' | 'pin-yellow' | 'pin-gray-selected' | 'pin-yellow-selected';
|
|
24
26
|
}
|
|
25
27
|
/**
|
|
26
28
|
* MarkerManager - Manages markers on the Leaflet map
|
|
@@ -74,6 +76,8 @@ export declare class MarkerManager {
|
|
|
74
76
|
private eventListeners;
|
|
75
77
|
private selectedIds;
|
|
76
78
|
private interactionConfig;
|
|
79
|
+
private defaultIconType;
|
|
80
|
+
private iconBasePath;
|
|
77
81
|
/**
|
|
78
82
|
* Creates a new MarkerManager instance
|
|
79
83
|
*
|
|
@@ -296,12 +300,69 @@ export declare class MarkerManager {
|
|
|
296
300
|
* @param eventType - Optional event type to clear
|
|
297
301
|
*/
|
|
298
302
|
removeAllListeners(eventType?: MarkerEventType): void;
|
|
303
|
+
/**
|
|
304
|
+
* Sets the default icon type for new markers
|
|
305
|
+
*
|
|
306
|
+
* @param iconType - Icon type to use as default
|
|
307
|
+
*/
|
|
308
|
+
setDefaultIconType(iconType: 'pin' | 'pin-gray' | 'pin-yellow' | 'pin-gray-selected' | 'pin-yellow-selected'): void;
|
|
309
|
+
/**
|
|
310
|
+
* Gets the current default icon type
|
|
311
|
+
*
|
|
312
|
+
* @returns Current default icon type
|
|
313
|
+
*/
|
|
314
|
+
getDefaultIconType(): 'pin' | 'pin-gray' | 'pin-yellow' | 'pin-gray-selected' | 'pin-yellow-selected';
|
|
315
|
+
/**
|
|
316
|
+
* Sets the base path for marker icons
|
|
317
|
+
*
|
|
318
|
+
* @param basePath - Base path for icon files (default: './images/')
|
|
319
|
+
*
|
|
320
|
+
* @example
|
|
321
|
+
* ```typescript
|
|
322
|
+
* // Use library's built-in icons (default)
|
|
323
|
+
* markerManager.setIconBasePath('./images/');
|
|
324
|
+
*
|
|
325
|
+
* // Use custom icons from public folder
|
|
326
|
+
* markerManager.setIconBasePath('/');
|
|
327
|
+
*
|
|
328
|
+
* // Use icons from a CDN
|
|
329
|
+
* markerManager.setIconBasePath('https://cdn.example.com/icons/');
|
|
330
|
+
* ```
|
|
331
|
+
*/
|
|
332
|
+
setIconBasePath(basePath: string): void;
|
|
333
|
+
/**
|
|
334
|
+
* Gets the current base path for marker icons
|
|
335
|
+
*
|
|
336
|
+
* @returns The current icon base path
|
|
337
|
+
*/
|
|
338
|
+
getIconBasePath(): string;
|
|
339
|
+
/**
|
|
340
|
+
* Updates the icon type for a specific marker
|
|
341
|
+
*
|
|
342
|
+
* @param id - Marker ID
|
|
343
|
+
* @param iconType - New icon type
|
|
344
|
+
* @returns True if marker was updated, false if not found
|
|
345
|
+
*/
|
|
346
|
+
updateMarkerIcon(id: string, iconType: 'pin' | 'pin-gray' | 'pin-yellow' | 'pin-gray-selected' | 'pin-yellow-selected'): boolean;
|
|
347
|
+
/**
|
|
348
|
+
* Updates all markers to use a new icon type
|
|
349
|
+
*
|
|
350
|
+
* @param iconType - Icon type to apply to all markers
|
|
351
|
+
*/
|
|
352
|
+
updateAllMarkerIcons(iconType: 'pin' | 'pin-gray' | 'pin-yellow' | 'pin-gray-selected' | 'pin-yellow-selected'): void;
|
|
299
353
|
/**
|
|
300
354
|
* Disposes of the marker manager and cleans up resources
|
|
301
355
|
*
|
|
302
356
|
* This should be called when the marker manager is no longer needed.
|
|
303
357
|
*/
|
|
304
358
|
dispose(): void;
|
|
359
|
+
/**
|
|
360
|
+
* Creates a custom icon for a marker
|
|
361
|
+
*
|
|
362
|
+
* @param iconType - Icon type to use
|
|
363
|
+
* @returns Leaflet icon instance
|
|
364
|
+
*/
|
|
365
|
+
private createCustomIcon;
|
|
305
366
|
/**
|
|
306
367
|
* Creates a Leaflet marker from marker data
|
|
307
368
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marker-manager.d.ts","sourceRoot":"","sources":["../../src/lib/marker-manager.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,SAAS,CAAC;AACxB,OAAO,KAAK,EACV,MAAM,EACN,UAAU,EACV,aAAa,EACb,WAAW,EACX,SAAS,EACT,WAAW,EACX,eAAe,EACf,uBAAuB,EACvB,oBAAoB,EACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAI1D;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,qCAAqC;IACrC,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,qCAAqC;IACrC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,gCAAgC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oCAAoC;IACpC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0BAA0B;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6BAA6B;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yBAAyB;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,wDAAwD;IACxD,EAAE,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"marker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,YAAY,GACZ,mBAAmB,GACnB,qBAAqB,GACxB,OAAO;IA8BV;;;;OAIG;IACH,oBAAoB,CAClB,QAAQ,EACJ,KAAK,GACL,UAAU,GACV,YAAY,GACZ,mBAAmB,GACnB,qBAAqB,GACxB,IAAI;IAkBP;;;;OAIG;IACH,OAAO,IAAI,IAAI;IAaf;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;IAoBxB;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;IA4C3B;;;;;OAKG;IACH,OAAO,CAAC,uBAAuB;IAmD/B;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAuCzB;;;;;OAKG;IACH,OAAO,CAAC,2BAA2B;IAwDnC;;;;;;OAMG;IACH,OAAO,CAAC,SAAS;IAyBjB;;;;;OAKG;IACH,OAAO,CAAC,UAAU;IAOlB;;;;;OAKG;IACH,OAAO,CAAC,kBAAkB;IAmD1B;;;;;OAKG;IACH,OAAO,CAAC,0BAA0B;IAyClC;;;;;OAKG;IACH,OAAO,CAAC,0BAA0B;IAgElC;;;;OAIG;YACW,UAAU;IAuCxB;;;;OAIG;YACW,YAAY;IA6B1B;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAgCtB;;;;;OAKG;IACH,OAAO,CAAC,kBAAkB;IAsE1B;;;;;OAKG;IACH,OAAO,CAAC,yBAAyB;IAwBjC;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;CAGzB"}
|
package/dist/styles.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CSS auto-loader for @edgepdf/viewer-js
|
|
3
|
+
*
|
|
4
|
+
* This file is automatically imported by the main index.ts file.
|
|
5
|
+
* It dynamically loads the CSS file at runtime, so users don't need to manually import CSS.
|
|
6
|
+
*
|
|
7
|
+
* The CSS is automatically injected when @edgepdf/viewer-js is imported.
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../src/styles.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAmCH,OAAO,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edgepdf/viewer-js",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "EdgePDF Viewer - JavaScript library for viewing PDF documents with interactive markers and zoom controls",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -30,8 +30,7 @@
|
|
|
30
30
|
"types": "./dist/index.d.ts",
|
|
31
31
|
"import": "./dist/index.js",
|
|
32
32
|
"default": "./dist/index.js"
|
|
33
|
-
}
|
|
34
|
-
"./styles.css": "./dist/styles.css"
|
|
33
|
+
}
|
|
35
34
|
},
|
|
36
35
|
"files": [
|
|
37
36
|
"dist",
|