mahal_map 1.5.9 → 1.6.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/README.md CHANGED
@@ -519,37 +519,6 @@ MahalMap.onReady("map", () => {
519
519
  map.destroy();
520
520
  ```
521
521
 
522
- ## Разработка
523
-
524
- ```sh
525
- npm run build
526
- npm run build:sdk
527
- npm run build:all
528
- npm test
529
- ```
530
-
531
- `npm run build` собирает npm entrypoint. `npm run build:sdk` собирает browser IIFE SDK bundle. `npm run build:all` запускает обе сборки.
532
-
533
- ## Структура проекта
534
-
535
- ```text
536
- src/
537
- index.ts
538
- sdk.ts
539
- config/
540
- core/
541
- markers/
542
- services/
543
- types/
544
- utils/
545
- ```
546
-
547
- - `index.ts` - npm entrypoint.
548
- - `sdk.ts` - browser SDK entrypoint.
549
- - `core/` - карта и управление камерой.
550
- - `markers/` - маркеры и адаптеры.
551
- - `types/` - публичные TypeScript типы.
552
-
553
522
  ## License
554
523
 
555
524
  ISC
package/dist/index.d.mts CHANGED
@@ -190,14 +190,14 @@ declare function Router(param: number[][], typeData: string, token: string): Pro
190
190
  declare function Search(param: string, token: string, additionalParam?: IAdditionalParamType): Promise<ISearchResponse[]>;
191
191
  declare function SearchByLocation(params: ISearchByLocationParam): Promise<ISearchResponse>;
192
192
 
193
- declare const index$1_Router: typeof Router;
194
- declare const index$1_Search: typeof Search;
195
- declare const index$1_SearchByLocation: typeof SearchByLocation;
196
- declare const index$1_clearKey: typeof clearKey;
197
- declare const index$1_getApiKey: typeof getApiKey;
198
- declare const index$1_saveKey: typeof saveKey;
199
- declare namespace index$1 {
200
- export { index$1_Router as Router, index$1_Search as Search, index$1_SearchByLocation as SearchByLocation, index$1_clearKey as clearKey, index$1_getApiKey as getApiKey, index$1_saveKey as saveKey };
193
+ declare const index$2_Router: typeof Router;
194
+ declare const index$2_Search: typeof Search;
195
+ declare const index$2_SearchByLocation: typeof SearchByLocation;
196
+ declare const index$2_clearKey: typeof clearKey;
197
+ declare const index$2_getApiKey: typeof getApiKey;
198
+ declare const index$2_saveKey: typeof saveKey;
199
+ declare namespace index$2 {
200
+ export { index$2_Router as Router, index$2_Search as Search, index$2_SearchByLocation as SearchByLocation, index$2_clearKey as clearKey, index$2_getApiKey as getApiKey, index$2_saveKey as saveKey };
201
201
  }
202
202
 
203
203
  declare class MahalMapDefaultMarker {
@@ -212,6 +212,164 @@ declare class MahalMapDefaultMarker {
212
212
  getAnchor(): "center" | "top" | "bottom" | "left" | "right" | "top-left" | "top-right" | "bottom-left" | "bottom-right";
213
213
  }
214
214
 
215
+ type MeasureMode = "distance" | "area";
216
+ interface MeasurePoint {
217
+ id: string;
218
+ lngLat: [number, number];
219
+ }
220
+ interface MeasureShape {
221
+ id: string;
222
+ mode: MeasureMode;
223
+ points: MeasurePoint[];
224
+ closed: boolean;
225
+ distance: number;
226
+ area: number;
227
+ }
228
+ interface MeasureStyleOptions {
229
+ pointColor?: string;
230
+ pointStrokeColor?: string;
231
+ pointStrokeWidth?: number;
232
+ pointRadius?: number;
233
+ activePointColor?: string;
234
+ lineColor?: string;
235
+ lineWidth?: number;
236
+ lineDasharray?: number[];
237
+ fillColor?: string;
238
+ fillOpacity?: number;
239
+ labelColor?: string;
240
+ labelHaloColor?: string;
241
+ badgeBackground?: string;
242
+ badgeTextColor?: string;
243
+ badgeBorderRadius?: string;
244
+ badgeBoxShadow?: string;
245
+ badgeBorder?: string;
246
+ badgeFontSize?: string;
247
+ badgeFontWeight?: string;
248
+ badgeGap?: string;
249
+ iconButtonSize?: string;
250
+ }
251
+ interface MeasureIcons {
252
+ trash?: string;
253
+ close?: string;
254
+ check?: string;
255
+ }
256
+ interface MeasureLabels {
257
+ meters?: string;
258
+ kilometers?: string;
259
+ squareMeters?: string;
260
+ squareKilometers?: string;
261
+ }
262
+ interface MeasureToolOptions {
263
+ mode?: MeasureMode;
264
+ sourceIdPrefix?: string;
265
+ style?: MeasureStyleOptions;
266
+ icons?: MeasureIcons;
267
+ labels?: MeasureLabels;
268
+ onChange?: (state: MeasureState) => void;
269
+ }
270
+ interface MeasureState {
271
+ active: boolean;
272
+ mode: MeasureMode;
273
+ draft: MeasureShape | null;
274
+ shapes: MeasureShape[];
275
+ }
276
+
277
+ declare class MeasureTool {
278
+ private map;
279
+ private prefix;
280
+ private style;
281
+ private labels;
282
+ private pointsSourceId;
283
+ private linesSourceId;
284
+ private fillsSourceId;
285
+ private labelsSourceId;
286
+ private pointsLayerId;
287
+ private linesCasingLayerId;
288
+ private linesLayerId;
289
+ private fillsLayerId;
290
+ private labelsLayerId;
291
+ private mode;
292
+ private isActive;
293
+ private draft;
294
+ private shapes;
295
+ private badge;
296
+ private draggingPointId;
297
+ private draggingShapeId;
298
+ private suppressNextClick;
299
+ private onChange?;
300
+ private handleClick;
301
+ private handlePointMouseDown;
302
+ private handlePointMouseEnter;
303
+ private handlePointMouseLeave;
304
+ private handlePointContextMenu;
305
+ private handleStyleLoad;
306
+ private handleViewportChange;
307
+ constructor(map: Map, options?: MeasureToolOptions);
308
+ start(mode?: MeasureMode): void;
309
+ stop(): void;
310
+ setMode(mode: MeasureMode): void;
311
+ finishDraft(): void;
312
+ removeShape(shapeId: string): void;
313
+ removePoint(shapeId: string, pointId: string): void;
314
+ clearAll(): void;
315
+ getState(): MeasureState;
316
+ destroy(): void;
317
+ private cloneShape;
318
+ private findShape;
319
+ private getLastShape;
320
+ private commitOrDiscardDraft;
321
+ private ensureDraft;
322
+ private recomputeShape;
323
+ private onMapClick;
324
+ private onPointMouseDown;
325
+ private onPointDragMove;
326
+ private onPointDragUp;
327
+ private stopDragListeners;
328
+ private onPointContextMenu;
329
+ private setCursor;
330
+ private onStyleLoad;
331
+ private emitChange;
332
+ private ensureLayers;
333
+ private removeLayers;
334
+ private setSourceData;
335
+ private buildLineFeature;
336
+ private buildFillFeature;
337
+ private buildPointFeatures;
338
+ private buildLabelFeature;
339
+ private render;
340
+ private updateBadge;
341
+ private updateBadgePosition;
342
+ }
343
+
344
+ declare function haversineDistance(a: [number, number], b: [number, number]): number;
345
+ declare function lineLength(points: [number, number][]): number;
346
+ /**
347
+ * Spherical excess polygon area (same approach as Leaflet.GeometryUtil / turf's
348
+ * geodesic area) — accurate enough for on-map measurement at city scale.
349
+ */
350
+ declare function polygonArea(points: [number, number][]): number;
351
+ declare function polygonCentroid(points: [number, number][]): [number, number];
352
+ declare function midpoint(points: [number, number][]): [number, number];
353
+
354
+ type index$1_MeasureIcons = MeasureIcons;
355
+ type index$1_MeasureLabels = MeasureLabels;
356
+ type index$1_MeasureMode = MeasureMode;
357
+ type index$1_MeasurePoint = MeasurePoint;
358
+ type index$1_MeasureShape = MeasureShape;
359
+ type index$1_MeasureState = MeasureState;
360
+ type index$1_MeasureStyleOptions = MeasureStyleOptions;
361
+ type index$1_MeasureTool = MeasureTool;
362
+ declare const index$1_MeasureTool: typeof MeasureTool;
363
+ type index$1_MeasureToolOptions = MeasureToolOptions;
364
+ declare const index$1_haversineDistance: typeof haversineDistance;
365
+ declare const index$1_lineLength: typeof lineLength;
366
+ declare const index$1_midpoint: typeof midpoint;
367
+ declare const index$1_polygonArea: typeof polygonArea;
368
+ declare const index$1_polygonCentroid: typeof polygonCentroid;
369
+ declare namespace index$1 {
370
+ export { type index$1_MeasureIcons as MeasureIcons, type index$1_MeasureLabels as MeasureLabels, type index$1_MeasureMode as MeasureMode, type index$1_MeasurePoint as MeasurePoint, type index$1_MeasureShape as MeasureShape, type index$1_MeasureState as MeasureState, type index$1_MeasureStyleOptions as MeasureStyleOptions, index$1_MeasureTool as MeasureTool, type index$1_MeasureToolOptions as MeasureToolOptions, index$1_haversineDistance as haversineDistance, index$1_lineLength as lineLength, index$1_midpoint as midpoint, index$1_polygonArea as polygonArea, index$1_polygonCentroid as polygonCentroid };
371
+ }
372
+
215
373
  declare function checkCoordinates(coordinates: string): {
216
374
  lat: string | undefined;
217
375
  lng: string | undefined;
@@ -234,4 +392,4 @@ declare namespace index {
234
392
  export { index_checkCoordinates as checkCoordinates, index_debounce as debounce, index_geojsonPolyline as geojsonPolyline, index_geometryPolyline as geometryPolyline, index_trimValue as trimValue };
235
393
  }
236
394
 
237
- export { type IAdditionalParamType, type IMahalMapOptions, type IMapMarker, type IResponse, type IRoute, type ISearchByLocationParam, type ISearchParam, type ISearchResponse, MahalMap, MahalMapDefaultMarker, type MahalMapDefaultMarkerProps, type MapLanguage, Router, Search, SearchByLocation, type Theme, index$1 as keyUtils, index as utils };
395
+ export { type IAdditionalParamType, type IMahalMapOptions, type IMapMarker, type IResponse, type IRoute, type ISearchByLocationParam, type ISearchParam, type ISearchResponse, MahalMap, MahalMapDefaultMarker, type MahalMapDefaultMarkerProps, type MapLanguage, type MeasureIcons, type MeasureLabels, type MeasureMode, type MeasurePoint, type MeasureShape, type MeasureState, type MeasureStyleOptions, MeasureTool, type MeasureToolOptions, Router, Search, SearchByLocation, type Theme, index$2 as keyUtils, index$1 as measureUtils, index as utils };
package/dist/index.d.ts CHANGED
@@ -190,14 +190,14 @@ declare function Router(param: number[][], typeData: string, token: string): Pro
190
190
  declare function Search(param: string, token: string, additionalParam?: IAdditionalParamType): Promise<ISearchResponse[]>;
191
191
  declare function SearchByLocation(params: ISearchByLocationParam): Promise<ISearchResponse>;
192
192
 
193
- declare const index$1_Router: typeof Router;
194
- declare const index$1_Search: typeof Search;
195
- declare const index$1_SearchByLocation: typeof SearchByLocation;
196
- declare const index$1_clearKey: typeof clearKey;
197
- declare const index$1_getApiKey: typeof getApiKey;
198
- declare const index$1_saveKey: typeof saveKey;
199
- declare namespace index$1 {
200
- export { index$1_Router as Router, index$1_Search as Search, index$1_SearchByLocation as SearchByLocation, index$1_clearKey as clearKey, index$1_getApiKey as getApiKey, index$1_saveKey as saveKey };
193
+ declare const index$2_Router: typeof Router;
194
+ declare const index$2_Search: typeof Search;
195
+ declare const index$2_SearchByLocation: typeof SearchByLocation;
196
+ declare const index$2_clearKey: typeof clearKey;
197
+ declare const index$2_getApiKey: typeof getApiKey;
198
+ declare const index$2_saveKey: typeof saveKey;
199
+ declare namespace index$2 {
200
+ export { index$2_Router as Router, index$2_Search as Search, index$2_SearchByLocation as SearchByLocation, index$2_clearKey as clearKey, index$2_getApiKey as getApiKey, index$2_saveKey as saveKey };
201
201
  }
202
202
 
203
203
  declare class MahalMapDefaultMarker {
@@ -212,6 +212,164 @@ declare class MahalMapDefaultMarker {
212
212
  getAnchor(): "center" | "top" | "bottom" | "left" | "right" | "top-left" | "top-right" | "bottom-left" | "bottom-right";
213
213
  }
214
214
 
215
+ type MeasureMode = "distance" | "area";
216
+ interface MeasurePoint {
217
+ id: string;
218
+ lngLat: [number, number];
219
+ }
220
+ interface MeasureShape {
221
+ id: string;
222
+ mode: MeasureMode;
223
+ points: MeasurePoint[];
224
+ closed: boolean;
225
+ distance: number;
226
+ area: number;
227
+ }
228
+ interface MeasureStyleOptions {
229
+ pointColor?: string;
230
+ pointStrokeColor?: string;
231
+ pointStrokeWidth?: number;
232
+ pointRadius?: number;
233
+ activePointColor?: string;
234
+ lineColor?: string;
235
+ lineWidth?: number;
236
+ lineDasharray?: number[];
237
+ fillColor?: string;
238
+ fillOpacity?: number;
239
+ labelColor?: string;
240
+ labelHaloColor?: string;
241
+ badgeBackground?: string;
242
+ badgeTextColor?: string;
243
+ badgeBorderRadius?: string;
244
+ badgeBoxShadow?: string;
245
+ badgeBorder?: string;
246
+ badgeFontSize?: string;
247
+ badgeFontWeight?: string;
248
+ badgeGap?: string;
249
+ iconButtonSize?: string;
250
+ }
251
+ interface MeasureIcons {
252
+ trash?: string;
253
+ close?: string;
254
+ check?: string;
255
+ }
256
+ interface MeasureLabels {
257
+ meters?: string;
258
+ kilometers?: string;
259
+ squareMeters?: string;
260
+ squareKilometers?: string;
261
+ }
262
+ interface MeasureToolOptions {
263
+ mode?: MeasureMode;
264
+ sourceIdPrefix?: string;
265
+ style?: MeasureStyleOptions;
266
+ icons?: MeasureIcons;
267
+ labels?: MeasureLabels;
268
+ onChange?: (state: MeasureState) => void;
269
+ }
270
+ interface MeasureState {
271
+ active: boolean;
272
+ mode: MeasureMode;
273
+ draft: MeasureShape | null;
274
+ shapes: MeasureShape[];
275
+ }
276
+
277
+ declare class MeasureTool {
278
+ private map;
279
+ private prefix;
280
+ private style;
281
+ private labels;
282
+ private pointsSourceId;
283
+ private linesSourceId;
284
+ private fillsSourceId;
285
+ private labelsSourceId;
286
+ private pointsLayerId;
287
+ private linesCasingLayerId;
288
+ private linesLayerId;
289
+ private fillsLayerId;
290
+ private labelsLayerId;
291
+ private mode;
292
+ private isActive;
293
+ private draft;
294
+ private shapes;
295
+ private badge;
296
+ private draggingPointId;
297
+ private draggingShapeId;
298
+ private suppressNextClick;
299
+ private onChange?;
300
+ private handleClick;
301
+ private handlePointMouseDown;
302
+ private handlePointMouseEnter;
303
+ private handlePointMouseLeave;
304
+ private handlePointContextMenu;
305
+ private handleStyleLoad;
306
+ private handleViewportChange;
307
+ constructor(map: Map, options?: MeasureToolOptions);
308
+ start(mode?: MeasureMode): void;
309
+ stop(): void;
310
+ setMode(mode: MeasureMode): void;
311
+ finishDraft(): void;
312
+ removeShape(shapeId: string): void;
313
+ removePoint(shapeId: string, pointId: string): void;
314
+ clearAll(): void;
315
+ getState(): MeasureState;
316
+ destroy(): void;
317
+ private cloneShape;
318
+ private findShape;
319
+ private getLastShape;
320
+ private commitOrDiscardDraft;
321
+ private ensureDraft;
322
+ private recomputeShape;
323
+ private onMapClick;
324
+ private onPointMouseDown;
325
+ private onPointDragMove;
326
+ private onPointDragUp;
327
+ private stopDragListeners;
328
+ private onPointContextMenu;
329
+ private setCursor;
330
+ private onStyleLoad;
331
+ private emitChange;
332
+ private ensureLayers;
333
+ private removeLayers;
334
+ private setSourceData;
335
+ private buildLineFeature;
336
+ private buildFillFeature;
337
+ private buildPointFeatures;
338
+ private buildLabelFeature;
339
+ private render;
340
+ private updateBadge;
341
+ private updateBadgePosition;
342
+ }
343
+
344
+ declare function haversineDistance(a: [number, number], b: [number, number]): number;
345
+ declare function lineLength(points: [number, number][]): number;
346
+ /**
347
+ * Spherical excess polygon area (same approach as Leaflet.GeometryUtil / turf's
348
+ * geodesic area) — accurate enough for on-map measurement at city scale.
349
+ */
350
+ declare function polygonArea(points: [number, number][]): number;
351
+ declare function polygonCentroid(points: [number, number][]): [number, number];
352
+ declare function midpoint(points: [number, number][]): [number, number];
353
+
354
+ type index$1_MeasureIcons = MeasureIcons;
355
+ type index$1_MeasureLabels = MeasureLabels;
356
+ type index$1_MeasureMode = MeasureMode;
357
+ type index$1_MeasurePoint = MeasurePoint;
358
+ type index$1_MeasureShape = MeasureShape;
359
+ type index$1_MeasureState = MeasureState;
360
+ type index$1_MeasureStyleOptions = MeasureStyleOptions;
361
+ type index$1_MeasureTool = MeasureTool;
362
+ declare const index$1_MeasureTool: typeof MeasureTool;
363
+ type index$1_MeasureToolOptions = MeasureToolOptions;
364
+ declare const index$1_haversineDistance: typeof haversineDistance;
365
+ declare const index$1_lineLength: typeof lineLength;
366
+ declare const index$1_midpoint: typeof midpoint;
367
+ declare const index$1_polygonArea: typeof polygonArea;
368
+ declare const index$1_polygonCentroid: typeof polygonCentroid;
369
+ declare namespace index$1 {
370
+ export { type index$1_MeasureIcons as MeasureIcons, type index$1_MeasureLabels as MeasureLabels, type index$1_MeasureMode as MeasureMode, type index$1_MeasurePoint as MeasurePoint, type index$1_MeasureShape as MeasureShape, type index$1_MeasureState as MeasureState, type index$1_MeasureStyleOptions as MeasureStyleOptions, index$1_MeasureTool as MeasureTool, type index$1_MeasureToolOptions as MeasureToolOptions, index$1_haversineDistance as haversineDistance, index$1_lineLength as lineLength, index$1_midpoint as midpoint, index$1_polygonArea as polygonArea, index$1_polygonCentroid as polygonCentroid };
371
+ }
372
+
215
373
  declare function checkCoordinates(coordinates: string): {
216
374
  lat: string | undefined;
217
375
  lng: string | undefined;
@@ -234,4 +392,4 @@ declare namespace index {
234
392
  export { index_checkCoordinates as checkCoordinates, index_debounce as debounce, index_geojsonPolyline as geojsonPolyline, index_geometryPolyline as geometryPolyline, index_trimValue as trimValue };
235
393
  }
236
394
 
237
- export { type IAdditionalParamType, type IMahalMapOptions, type IMapMarker, type IResponse, type IRoute, type ISearchByLocationParam, type ISearchParam, type ISearchResponse, MahalMap, MahalMapDefaultMarker, type MahalMapDefaultMarkerProps, type MapLanguage, Router, Search, SearchByLocation, type Theme, index$1 as keyUtils, index as utils };
395
+ export { type IAdditionalParamType, type IMahalMapOptions, type IMapMarker, type IResponse, type IRoute, type ISearchByLocationParam, type ISearchParam, type ISearchResponse, MahalMap, MahalMapDefaultMarker, type MahalMapDefaultMarkerProps, type MapLanguage, type MeasureIcons, type MeasureLabels, type MeasureMode, type MeasurePoint, type MeasureShape, type MeasureState, type MeasureStyleOptions, MeasureTool, type MeasureToolOptions, Router, Search, SearchByLocation, type Theme, index$2 as keyUtils, index$1 as measureUtils, index as utils };