mahal_map 2.0.0 → 2.0.1
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 +231 -38
- package/dist/index.d.mts +105 -9
- package/dist/index.d.ts +105 -9
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -3
- package/dist/index.mjs.map +1 -1
- package/dist/mahal_map.sdk.js +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -26,17 +26,64 @@ interface IAdditionalParamType {
|
|
|
26
26
|
* более старая сборка на странице не ломала типы у потребителя.
|
|
27
27
|
*/
|
|
28
28
|
type Maps3DThemeName = "light" | "dark" | "navigator-light" | "navigator-dark" | "mobile-light" | "mobile-dark";
|
|
29
|
-
/** Идентификатор слоя в реестре: buildings, objects, traffic, terrain, indoor, closures, parking, fuel, charging. */
|
|
30
|
-
type Maps3DLayerId = string;
|
|
31
29
|
/** Уровень детализации зданий. */
|
|
32
30
|
type Maps3DBuildingDetail = "footprint" | "volume" | "roofs" | "facade";
|
|
31
|
+
/** Режим рельефа: `auto` показывает его на обзорных зумах, `on` — всегда (дороже по трафику и кадру). */
|
|
32
|
+
type Maps3DTerrainMode = "auto" | "on" | "off";
|
|
33
|
+
/**
|
|
34
|
+
* Параметры каждого слоя реестра. Служит и справочником, и источником типов:
|
|
35
|
+
* ключи дают список id, значения — допустимые `params` в setLayer().
|
|
36
|
+
*
|
|
37
|
+
* У самой Maps3D id слоя типизирован как `string`, поэтому опечатка там проходит
|
|
38
|
+
* компиляцию и проваливается в рантайме (setLayer вернёт false). Здесь список
|
|
39
|
+
* фиксирован по таблице слоёв 0.7.3 — промах ловится на сборке.
|
|
40
|
+
*/
|
|
41
|
+
interface IMaps3DLayerParams {
|
|
42
|
+
/** Объёмные здания. По умолчанию включён. */
|
|
43
|
+
buildings: {
|
|
44
|
+
detail?: Maps3DBuildingDetail;
|
|
45
|
+
};
|
|
46
|
+
/** Расставленные 3D-объекты. По умолчанию включён. */
|
|
47
|
+
objects: Record<string, never>;
|
|
48
|
+
/** Пробки векторным слоем. По умолчанию выключен. */
|
|
49
|
+
traffic: Record<string, never>;
|
|
50
|
+
/** Пробки картинкой с сервера, без клика по дороге. По умолчанию выключен. */
|
|
51
|
+
trafficRaster: Record<string, never>;
|
|
52
|
+
/**
|
|
53
|
+
* Парковки. По умолчанию включён. Подтип берётся из атрибута `fee`:
|
|
54
|
+
* `paid` — `fee=yes`, `free` — `fee=no`, `unknown` — атрибута нет.
|
|
55
|
+
*/
|
|
56
|
+
parking: {
|
|
57
|
+
highlight?: boolean;
|
|
58
|
+
paid?: boolean;
|
|
59
|
+
free?: boolean;
|
|
60
|
+
unknown?: boolean;
|
|
61
|
+
};
|
|
62
|
+
/** Заправки. По умолчанию включён. */
|
|
63
|
+
fuel: Record<string, never>;
|
|
64
|
+
/** Зарядки. По умолчанию включён. */
|
|
65
|
+
charging: Record<string, never>;
|
|
66
|
+
/** Перекрытия дорог. По умолчанию выключен, требует своего тайлсета. */
|
|
67
|
+
closures: Record<string, never>;
|
|
68
|
+
/** Планы этажей. По умолчанию выключен, требует данных по зданию. */
|
|
69
|
+
indoor: {
|
|
70
|
+
level?: number;
|
|
71
|
+
};
|
|
72
|
+
/** Рельеф. По умолчанию `auto`. */
|
|
73
|
+
terrain: {
|
|
74
|
+
mode?: Maps3DTerrainMode;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/** Идентификатор слоя в реестре Maps3D. */
|
|
78
|
+
type Maps3DLayerId = keyof IMaps3DLayerParams;
|
|
33
79
|
/**
|
|
34
80
|
* Снимок состояния слоя. Три поля независимы: слой может быть включён клиентом (`wanted`),
|
|
35
81
|
* но не нарисован — рельеф в режиме auto ждёт обзорного зума, перекрытия ждут своего
|
|
36
82
|
* тайлсета, планы этажей — данных по зданию.
|
|
37
83
|
*/
|
|
38
84
|
interface IMaps3DLayerState {
|
|
39
|
-
|
|
85
|
+
/** Не сужен до Maps3DLayerId: сборка Maps3D может отдать слой, которого нет в нашем списке. */
|
|
86
|
+
id: string;
|
|
40
87
|
/** Чего хочет клиент: последний setLayer либо умолчание стиля. */
|
|
41
88
|
wanted: boolean;
|
|
42
89
|
/** Что позволяет стиль: объявлен ли слой и есть ли под него данные. */
|
|
@@ -150,8 +197,8 @@ interface IMaps3DLayer {
|
|
|
150
197
|
readonly ready?: Promise<void>;
|
|
151
198
|
destroy?(): void;
|
|
152
199
|
remove?(): void;
|
|
153
|
-
setLayer?(id:
|
|
154
|
-
layer?(id:
|
|
200
|
+
setLayer?(id: string, on: boolean, params?: Record<string, unknown>): boolean;
|
|
201
|
+
layer?(id: string): IMaps3DLayerState | null;
|
|
155
202
|
layers?(): IMaps3DLayerState[];
|
|
156
203
|
onLayers?(callback: (state: IMaps3DLayerState) => void): () => void;
|
|
157
204
|
refreshLayers?(): void;
|
|
@@ -255,6 +302,12 @@ interface IMahalMapOptions {
|
|
|
255
302
|
antialias?: boolean;
|
|
256
303
|
/** Опции Maps3D: buildings, traffic, indoor, closures, terrain, minZoom, lodBias, memoryBudget, ... */
|
|
257
304
|
maps3d?: Omit<IMaps3DLayerOptions, "apiKey" | "base">;
|
|
305
|
+
/**
|
|
306
|
+
* Диагностика неработающего веб-воркера MapLibre: если через 8 с после создания карты
|
|
307
|
+
* не разобран ни один векторный тайл, в консоль уходит предупреждение с причиной и
|
|
308
|
+
* решением. `false` отключает проверку, число задаёт свою задержку в мс.
|
|
309
|
+
*/
|
|
310
|
+
workerCheck?: boolean | number;
|
|
258
311
|
/**
|
|
259
312
|
* @deprecated Игнорируется с 2.0.0. Движок один — платформа MahalMaps через
|
|
260
313
|
* @grammaps/maps3d-web. Без переданного Maps3D карта поднимается на запасном стиле.
|
|
@@ -382,6 +435,8 @@ declare class MahalMap {
|
|
|
382
435
|
private static instances;
|
|
383
436
|
private static defaultLanguage;
|
|
384
437
|
private static disposedMaps3DLayers;
|
|
438
|
+
/** Через сколько мс после создания карты проверяем, ожил ли веб-воркер MapLibre. */
|
|
439
|
+
private static readonly WORKER_CHECK_DELAY;
|
|
385
440
|
private isReady;
|
|
386
441
|
private readyCallbacks;
|
|
387
442
|
private map;
|
|
@@ -400,6 +455,7 @@ declare class MahalMap {
|
|
|
400
455
|
private maps3dLayer?;
|
|
401
456
|
private maps3dReady?;
|
|
402
457
|
private buildingsEnabled;
|
|
458
|
+
private workerCheckTimer?;
|
|
403
459
|
private constructor();
|
|
404
460
|
private static getInstanceKey;
|
|
405
461
|
private static normalizeLanguage;
|
|
@@ -453,11 +509,15 @@ declare class MahalMap {
|
|
|
453
509
|
static getMaps3DLayer(instance: MahalMap): IMaps3DLayer | undefined;
|
|
454
510
|
static whenMaps3DReady(instance: MahalMap): Promise<IMaps3DLayer | undefined>;
|
|
455
511
|
static toggle3DBuildings(instance: MahalMap, enabled: boolean): void;
|
|
456
|
-
static setLayer(instance: MahalMap, id:
|
|
512
|
+
static setLayer<Id extends Maps3DLayerId>(instance: MahalMap, id: Id, on: boolean, params?: IMaps3DLayerParams[Id]): boolean;
|
|
457
513
|
static getLayerState(instance: MahalMap, id: Maps3DLayerId): IMaps3DLayerState | null;
|
|
458
514
|
static getLayers(instance: MahalMap): IMaps3DLayerState[];
|
|
459
515
|
static onLayers(instance: MahalMap, callback: (state: IMaps3DLayerState) => void): () => void;
|
|
460
516
|
static refreshLayers(instance: MahalMap): void;
|
|
517
|
+
static getIndoorLevels(instance: MahalMap): number[];
|
|
518
|
+
static setIndoorLevel(instance: MahalMap, level: number): void;
|
|
519
|
+
static refreshIndoor(instance: MahalMap): void;
|
|
520
|
+
static showPlace(instance: MahalMap, lon: number, lat: number, level?: number | null, zoom?: number): void;
|
|
461
521
|
static onBuildingClick(instance: MahalMap, callback: (info: IMaps3DBuildingClickInfo | null) => void): void;
|
|
462
522
|
static selectBuilding(instance: MahalMap, id: number | string | null, style?: IMaps3DSelectionStyle): boolean;
|
|
463
523
|
static clearSelection(instance: MahalMap): void;
|
|
@@ -500,8 +560,15 @@ declare class MahalMap {
|
|
|
500
560
|
* Резолвится в undefined, если слой выключен, Maps3D не передан или подключение упало.
|
|
501
561
|
*/
|
|
502
562
|
whenMaps3DReady(): Promise<IMaps3DLayer | undefined>;
|
|
503
|
-
/**
|
|
504
|
-
|
|
563
|
+
/**
|
|
564
|
+
* Включить/выключить слой. `params` типизирован под конкретный слой: `terrain` ждёт
|
|
565
|
+
* `{ mode }`, `buildings` — `{ detail }`, `indoor` — `{ level }`, у остальных параметров нет.
|
|
566
|
+
*
|
|
567
|
+
* Возвращает `false`, если такого слоя в подключённой сборке Maps3D нет или Maps3D не передан.
|
|
568
|
+
* Слой, которого ещё нет в нашем списке id, доступен напрямую:
|
|
569
|
+
* `map.getMaps3DLayer()?.setLayer?.("новый", true)`.
|
|
570
|
+
*/
|
|
571
|
+
setLayer<Id extends Maps3DLayerId>(id: Id, on: boolean, params?: IMaps3DLayerParams[Id]): boolean;
|
|
505
572
|
/** Состояние слоя: wanted (воля клиента), available (позволяет стиль), active (нарисовано). */
|
|
506
573
|
getLayerState(id: Maps3DLayerId): IMaps3DLayerState | null;
|
|
507
574
|
/** Снимок всех слоёв — по нему приложение рисует свою панель. */
|
|
@@ -510,6 +577,18 @@ declare class MahalMap {
|
|
|
510
577
|
onLayers(callback: (state: IMaps3DLayerState) => void): () => void;
|
|
511
578
|
/** Пере-применить волю клиента ко всем слоям — после полной смены стиля. */
|
|
512
579
|
refreshLayers(): void;
|
|
580
|
+
/** Этажи, найденные в текущем виде карты. Пусто — данных по зданию нет. */
|
|
581
|
+
getIndoorLevels(): number[];
|
|
582
|
+
/** Переключить этаж. Нумерация OSM: 0 — первый наземный. */
|
|
583
|
+
setIndoorLevel(level: number): void;
|
|
584
|
+
/** Перечитать планы этажей — после правки картографом. */
|
|
585
|
+
refreshIndoor(): void;
|
|
586
|
+
/**
|
|
587
|
+
* Показать найденный объект и открыть его этаж. Ровно то, что нужно после поиска:
|
|
588
|
+
* у объектов внутри зданий приходит `level` — без него карта откроет первый этаж
|
|
589
|
+
* и метка окажется в чужом зале.
|
|
590
|
+
*/
|
|
591
|
+
showPlace(lon: number, lat: number, level?: number | null, zoom?: number): void;
|
|
513
592
|
/** Клик по зданию: { id, height, props } либо null. Повторный вызов заменяет обработчик. */
|
|
514
593
|
onBuildingClick(callback: (info: IMaps3DBuildingClickInfo | null) => void): void;
|
|
515
594
|
/** Выделить здание по osm_id. `false` — здания сейчас нет в загруженных данных. */
|
|
@@ -539,6 +618,23 @@ declare class MahalMap {
|
|
|
539
618
|
* вызов teardown попал бы на уже освобождённый объект.
|
|
540
619
|
*/
|
|
541
620
|
private static teardownMaps3DLayer;
|
|
621
|
+
/**
|
|
622
|
+
* Диагностика неработающего веб-воркера MapLibre.
|
|
623
|
+
*
|
|
624
|
+
* Симптом злой: тайлы приходят, но разобрать их некому — карта показывает пустой фон,
|
|
625
|
+
* а в консоли лежит только `Uncaught SyntaxError: Unexpected token '<'`, где нет ни слова
|
|
626
|
+
* ни про MapLibre, ни про воркер. Причина почти всегда одна: сборщик не перенёс файл
|
|
627
|
+
* воркера рядом со сборкой, и вместо скрипта сервер отдаёт index.html.
|
|
628
|
+
*
|
|
629
|
+
* Проверку вешаем на таймер от создания карты, а НЕ на событие "load": при мёртвом
|
|
630
|
+
* воркере стиль не дозагружается и "load" не приходит вовсе.
|
|
631
|
+
*
|
|
632
|
+
* Смотрим на результат, а не на события: у Maps3D свой сторож (`gn`) слушает
|
|
633
|
+
* `data{sourceDataType:"content"}`, но это событие приходит при регистрации источника,
|
|
634
|
+
* за ~30 мс и без единого тайла — тревога снимается раньше, чем что-то могло сломаться.
|
|
635
|
+
*/
|
|
636
|
+
private watchWorkerHealth;
|
|
637
|
+
private reportBrokenWorker;
|
|
542
638
|
/**
|
|
543
639
|
* Приводит объём зданий к желаемому состоянию. Реестр слоёв (0.7.x) — основная дверь:
|
|
544
640
|
* он же прячет и возвращает штатные здания стиля. setBuildingsEnabled — путь для
|
|
@@ -821,4 +917,4 @@ declare namespace index {
|
|
|
821
917
|
export { index_checkCoordinates as checkCoordinates, index_debounce as debounce, index_geojsonPolyline as geojsonPolyline, index_geometryPolyline as geometryPolyline, index_trimValue as trimValue };
|
|
822
918
|
}
|
|
823
919
|
|
|
824
|
-
export { CheckJSApi, type IAdditionalParamType, type ICheckJSApiParam, type ICheckJSApiResponse, type IMahalMapOptions, type IMapMarker, type IMaps3DBuildingClickInfo, type IMaps3DBuildingsController, type IMaps3DBuildingsOptions, type IMaps3DClosuresOptions, type IMaps3DDiagnostics, type IMaps3DIndoorOptions, type IMaps3DLayer, type IMaps3DLayerOptions, type IMaps3DLayerState, type IMaps3DMapOptionsInput, type IMaps3DMapOptionsResult, type IMaps3DObjectsLightOptions, type IMaps3DPlacesOptions, type IMaps3DRoadHit, type IMaps3DSelectionStyle, type IMaps3DTrafficOptions, type IMaps3DTransformRequestOptions, type IResponse, type IRoute, type ISearchByLocationParam, type ISearchParam, type ISearchResponse, MahalMap, MahalMapDefaultMarker, type MahalMapDefaultMarkerProps, type MapEngine, type MapLanguage, type MapStyleFamily, type Maps3DBuildingDetail, type Maps3DCtor, type Maps3DLayerId, type Maps3DThemeName, type Maps3DTransformRequest, type MeasureIcons, type MeasureLabels, type MeasureMode, type MeasurePoint, type MeasureShape, type MeasureState, type MeasureStyleOptions, MeasureTool, type MeasureToolOptions, Router, Search, SearchByLocation, SearchPoi, type Theme, index$2 as keyUtils, index$1 as measureUtils, index as utils };
|
|
920
|
+
export { CheckJSApi, type IAdditionalParamType, type ICheckJSApiParam, type ICheckJSApiResponse, type IMahalMapOptions, type IMapMarker, type IMaps3DBuildingClickInfo, type IMaps3DBuildingsController, type IMaps3DBuildingsOptions, type IMaps3DClosuresOptions, type IMaps3DDiagnostics, type IMaps3DIndoorOptions, type IMaps3DLayer, type IMaps3DLayerOptions, type IMaps3DLayerParams, type IMaps3DLayerState, type IMaps3DMapOptionsInput, type IMaps3DMapOptionsResult, type IMaps3DObjectsLightOptions, type IMaps3DPlacesOptions, type IMaps3DRoadHit, type IMaps3DSelectionStyle, type IMaps3DTrafficOptions, type IMaps3DTransformRequestOptions, type IResponse, type IRoute, type ISearchByLocationParam, type ISearchParam, type ISearchResponse, MahalMap, MahalMapDefaultMarker, type MahalMapDefaultMarkerProps, type MapEngine, type MapLanguage, type MapStyleFamily, type Maps3DBuildingDetail, type Maps3DCtor, type Maps3DLayerId, type Maps3DTerrainMode, type Maps3DThemeName, type Maps3DTransformRequest, type MeasureIcons, type MeasureLabels, type MeasureMode, type MeasurePoint, type MeasureShape, type MeasureState, type MeasureStyleOptions, MeasureTool, type MeasureToolOptions, Router, Search, SearchByLocation, SearchPoi, type Theme, index$2 as keyUtils, index$1 as measureUtils, index as utils };
|