mahal_map 2.0.0 → 2.0.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 +408 -173
- package/dist/index.d.mts +127 -12
- package/dist/index.d.ts +127 -12
- 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 +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as maplibre_gl from 'maplibre-gl';
|
|
1
2
|
import { Map, FlyToOptions, Marker } from 'maplibre-gl';
|
|
2
3
|
|
|
3
4
|
declare class CameraController {
|
|
@@ -26,17 +27,64 @@ interface IAdditionalParamType {
|
|
|
26
27
|
* более старая сборка на странице не ломала типы у потребителя.
|
|
27
28
|
*/
|
|
28
29
|
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
30
|
/** Уровень детализации зданий. */
|
|
32
31
|
type Maps3DBuildingDetail = "footprint" | "volume" | "roofs" | "facade";
|
|
32
|
+
/** Режим рельефа: `auto` показывает его на обзорных зумах, `on` — всегда (дороже по трафику и кадру). */
|
|
33
|
+
type Maps3DTerrainMode = "auto" | "on" | "off";
|
|
34
|
+
/**
|
|
35
|
+
* Параметры каждого слоя реестра. Служит и справочником, и источником типов:
|
|
36
|
+
* ключи дают список id, значения — допустимые `params` в setLayer().
|
|
37
|
+
*
|
|
38
|
+
* У самой Maps3D id слоя типизирован как `string`, поэтому опечатка там проходит
|
|
39
|
+
* компиляцию и проваливается в рантайме (setLayer вернёт false). Здесь список
|
|
40
|
+
* фиксирован по таблице слоёв 0.7.3 — промах ловится на сборке.
|
|
41
|
+
*/
|
|
42
|
+
interface IMaps3DLayerParams {
|
|
43
|
+
/** Объёмные здания. По умолчанию включён. */
|
|
44
|
+
buildings: {
|
|
45
|
+
detail?: Maps3DBuildingDetail;
|
|
46
|
+
};
|
|
47
|
+
/** Расставленные 3D-объекты. По умолчанию включён. */
|
|
48
|
+
objects: Record<string, never>;
|
|
49
|
+
/** Пробки векторным слоем. По умолчанию выключен. */
|
|
50
|
+
traffic: Record<string, never>;
|
|
51
|
+
/** Пробки картинкой с сервера, без клика по дороге. По умолчанию выключен. */
|
|
52
|
+
trafficRaster: Record<string, never>;
|
|
53
|
+
/**
|
|
54
|
+
* Парковки. По умолчанию включён. Подтип берётся из атрибута `fee`:
|
|
55
|
+
* `paid` — `fee=yes`, `free` — `fee=no`, `unknown` — атрибута нет.
|
|
56
|
+
*/
|
|
57
|
+
parking: {
|
|
58
|
+
highlight?: boolean;
|
|
59
|
+
paid?: boolean;
|
|
60
|
+
free?: boolean;
|
|
61
|
+
unknown?: boolean;
|
|
62
|
+
};
|
|
63
|
+
/** Заправки. По умолчанию включён. */
|
|
64
|
+
fuel: Record<string, never>;
|
|
65
|
+
/** Зарядки. По умолчанию включён. */
|
|
66
|
+
charging: Record<string, never>;
|
|
67
|
+
/** Перекрытия дорог. По умолчанию выключен, требует своего тайлсета. */
|
|
68
|
+
closures: Record<string, never>;
|
|
69
|
+
/** Планы этажей. По умолчанию выключен, требует данных по зданию. */
|
|
70
|
+
indoor: {
|
|
71
|
+
level?: number;
|
|
72
|
+
};
|
|
73
|
+
/** Рельеф. По умолчанию `auto`. */
|
|
74
|
+
terrain: {
|
|
75
|
+
mode?: Maps3DTerrainMode;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/** Идентификатор слоя в реестре Maps3D. */
|
|
79
|
+
type Maps3DLayerId = keyof IMaps3DLayerParams;
|
|
33
80
|
/**
|
|
34
81
|
* Снимок состояния слоя. Три поля независимы: слой может быть включён клиентом (`wanted`),
|
|
35
82
|
* но не нарисован — рельеф в режиме auto ждёт обзорного зума, перекрытия ждут своего
|
|
36
83
|
* тайлсета, планы этажей — данных по зданию.
|
|
37
84
|
*/
|
|
38
85
|
interface IMaps3DLayerState {
|
|
39
|
-
|
|
86
|
+
/** Не сужен до Maps3DLayerId: сборка Maps3D может отдать слой, которого нет в нашем списке. */
|
|
87
|
+
id: string;
|
|
40
88
|
/** Чего хочет клиент: последний setLayer либо умолчание стиля. */
|
|
41
89
|
wanted: boolean;
|
|
42
90
|
/** Что позволяет стиль: объявлен ли слой и есть ли под него данные. */
|
|
@@ -150,8 +198,8 @@ interface IMaps3DLayer {
|
|
|
150
198
|
readonly ready?: Promise<void>;
|
|
151
199
|
destroy?(): void;
|
|
152
200
|
remove?(): void;
|
|
153
|
-
setLayer?(id:
|
|
154
|
-
layer?(id:
|
|
201
|
+
setLayer?(id: string, on: boolean, params?: Record<string, unknown>): boolean;
|
|
202
|
+
layer?(id: string): IMaps3DLayerState | null;
|
|
155
203
|
layers?(): IMaps3DLayerState[];
|
|
156
204
|
onLayers?(callback: (state: IMaps3DLayerState) => void): () => void;
|
|
157
205
|
refreshLayers?(): void;
|
|
@@ -216,10 +264,13 @@ type Maps3DCtor = (new (options: IMaps3DLayerOptions) => IMaps3DLayer) & {
|
|
|
216
264
|
styleUrl?(style?: string, base?: string): string;
|
|
217
265
|
/** Подключение к уже созданной карте; возвращает экземпляр с `ready`. */
|
|
218
266
|
enhance?(map: Map, options?: IMaps3DLayerOptions): IMaps3DLayer;
|
|
219
|
-
/**
|
|
267
|
+
/**
|
|
268
|
+
* MapLibre с платформы вместе со своим воркером. Возвращает то же, что
|
|
269
|
+
* `import * as maplibregl from "maplibre-gl"` — декларации гарантирует peerDependency.
|
|
270
|
+
*/
|
|
220
271
|
maplibre?(options?: {
|
|
221
272
|
base?: string;
|
|
222
|
-
}): Promise<
|
|
273
|
+
}): Promise<typeof maplibre_gl>;
|
|
223
274
|
readonly maplibreVersion?: string;
|
|
224
275
|
};
|
|
225
276
|
|
|
@@ -255,6 +306,12 @@ interface IMahalMapOptions {
|
|
|
255
306
|
antialias?: boolean;
|
|
256
307
|
/** Опции Maps3D: buildings, traffic, indoor, closures, terrain, minZoom, lodBias, memoryBudget, ... */
|
|
257
308
|
maps3d?: Omit<IMaps3DLayerOptions, "apiKey" | "base">;
|
|
309
|
+
/**
|
|
310
|
+
* Диагностика неработающего веб-воркера MapLibre: если через 8 с после создания карты
|
|
311
|
+
* не разобран ни один векторный тайл, в консоль уходит предупреждение с причиной и
|
|
312
|
+
* решением. `false` отключает проверку, число задаёт свою задержку в мс.
|
|
313
|
+
*/
|
|
314
|
+
workerCheck?: boolean | number;
|
|
258
315
|
/**
|
|
259
316
|
* @deprecated Игнорируется с 2.0.0. Движок один — платформа MahalMaps через
|
|
260
317
|
* @grammaps/maps3d-web. Без переданного Maps3D карта поднимается на запасном стиле.
|
|
@@ -382,6 +439,8 @@ declare class MahalMap {
|
|
|
382
439
|
private static instances;
|
|
383
440
|
private static defaultLanguage;
|
|
384
441
|
private static disposedMaps3DLayers;
|
|
442
|
+
/** Через сколько мс после создания карты проверяем, ожил ли веб-воркер MapLibre. */
|
|
443
|
+
private static readonly WORKER_CHECK_DELAY;
|
|
385
444
|
private isReady;
|
|
386
445
|
private readyCallbacks;
|
|
387
446
|
private map;
|
|
@@ -400,6 +459,8 @@ declare class MahalMap {
|
|
|
400
459
|
private maps3dLayer?;
|
|
401
460
|
private maps3dReady?;
|
|
402
461
|
private buildingsEnabled;
|
|
462
|
+
private workerCheckTimer?;
|
|
463
|
+
private styleChangeHandler?;
|
|
403
464
|
private constructor();
|
|
404
465
|
private static getInstanceKey;
|
|
405
466
|
private static normalizeLanguage;
|
|
@@ -453,11 +514,15 @@ declare class MahalMap {
|
|
|
453
514
|
static getMaps3DLayer(instance: MahalMap): IMaps3DLayer | undefined;
|
|
454
515
|
static whenMaps3DReady(instance: MahalMap): Promise<IMaps3DLayer | undefined>;
|
|
455
516
|
static toggle3DBuildings(instance: MahalMap, enabled: boolean): void;
|
|
456
|
-
static setLayer(instance: MahalMap, id:
|
|
517
|
+
static setLayer<Id extends Maps3DLayerId>(instance: MahalMap, id: Id, on: boolean, params?: IMaps3DLayerParams[Id]): boolean;
|
|
457
518
|
static getLayerState(instance: MahalMap, id: Maps3DLayerId): IMaps3DLayerState | null;
|
|
458
519
|
static getLayers(instance: MahalMap): IMaps3DLayerState[];
|
|
459
520
|
static onLayers(instance: MahalMap, callback: (state: IMaps3DLayerState) => void): () => void;
|
|
460
521
|
static refreshLayers(instance: MahalMap): void;
|
|
522
|
+
static getIndoorLevels(instance: MahalMap): number[];
|
|
523
|
+
static setIndoorLevel(instance: MahalMap, level: number): void;
|
|
524
|
+
static refreshIndoor(instance: MahalMap): void;
|
|
525
|
+
static showPlace(instance: MahalMap, lon: number, lat: number, level?: number | null, zoom?: number): void;
|
|
461
526
|
static onBuildingClick(instance: MahalMap, callback: (info: IMaps3DBuildingClickInfo | null) => void): void;
|
|
462
527
|
static selectBuilding(instance: MahalMap, id: number | string | null, style?: IMaps3DSelectionStyle): boolean;
|
|
463
528
|
static clearSelection(instance: MahalMap): void;
|
|
@@ -482,7 +547,21 @@ declare class MahalMap {
|
|
|
482
547
|
* Без Maps3D менять нечего — карта на запасном стиле, у него варианта по теме нет.
|
|
483
548
|
*/
|
|
484
549
|
setStyle(theme: Theme): void;
|
|
485
|
-
|
|
550
|
+
/**
|
|
551
|
+
* Адрес стиля по имени темы. mapOptions() — основной контракт (есть с 0.5.0);
|
|
552
|
+
* styleUrl остаётся запасным путём для сборок, где mapOptions ещё нет.
|
|
553
|
+
* Раньше здесь был только styleUrl, и сборка с одним mapOptions() тему не меняла.
|
|
554
|
+
*/
|
|
555
|
+
private resolvePlatformStyle;
|
|
556
|
+
/**
|
|
557
|
+
* Полная смена стиля уносит слои Maps3D вместе с ним — реестр умеет вернуть волю
|
|
558
|
+
* клиента, но только когда новый стиль уже загружен.
|
|
559
|
+
*
|
|
560
|
+
* Слушаем styledata, а не style.load: setStyle() идёт через дифф и style.load при
|
|
561
|
+
* этом не поднимает — с ним восстановление просто не случалось. styledata приходит
|
|
562
|
+
* многократно, поэтому ждём isStyleLoaded() и снимаем обработчик сами.
|
|
563
|
+
*/
|
|
564
|
+
private refreshLayersOnStyleChange;
|
|
486
565
|
/**
|
|
487
566
|
* Язык подписей приходит из стиля платформы, отдельных URL по языкам больше нет —
|
|
488
567
|
* метод только запоминает выбор для остальных сервисов SDK (поиск, роутинг).
|
|
@@ -500,8 +579,15 @@ declare class MahalMap {
|
|
|
500
579
|
* Резолвится в undefined, если слой выключен, Maps3D не передан или подключение упало.
|
|
501
580
|
*/
|
|
502
581
|
whenMaps3DReady(): Promise<IMaps3DLayer | undefined>;
|
|
503
|
-
/**
|
|
504
|
-
|
|
582
|
+
/**
|
|
583
|
+
* Включить/выключить слой. `params` типизирован под конкретный слой: `terrain` ждёт
|
|
584
|
+
* `{ mode }`, `buildings` — `{ detail }`, `indoor` — `{ level }`, у остальных параметров нет.
|
|
585
|
+
*
|
|
586
|
+
* Возвращает `false`, если такого слоя в подключённой сборке Maps3D нет или Maps3D не передан.
|
|
587
|
+
* Слой, которого ещё нет в нашем списке id, доступен напрямую:
|
|
588
|
+
* `map.getMaps3DLayer()?.setLayer?.("новый", true)`.
|
|
589
|
+
*/
|
|
590
|
+
setLayer<Id extends Maps3DLayerId>(id: Id, on: boolean, params?: IMaps3DLayerParams[Id]): boolean;
|
|
505
591
|
/** Состояние слоя: wanted (воля клиента), available (позволяет стиль), active (нарисовано). */
|
|
506
592
|
getLayerState(id: Maps3DLayerId): IMaps3DLayerState | null;
|
|
507
593
|
/** Снимок всех слоёв — по нему приложение рисует свою панель. */
|
|
@@ -510,6 +596,18 @@ declare class MahalMap {
|
|
|
510
596
|
onLayers(callback: (state: IMaps3DLayerState) => void): () => void;
|
|
511
597
|
/** Пере-применить волю клиента ко всем слоям — после полной смены стиля. */
|
|
512
598
|
refreshLayers(): void;
|
|
599
|
+
/** Этажи, найденные в текущем виде карты. Пусто — данных по зданию нет. */
|
|
600
|
+
getIndoorLevels(): number[];
|
|
601
|
+
/** Переключить этаж. Нумерация OSM: 0 — первый наземный. */
|
|
602
|
+
setIndoorLevel(level: number): void;
|
|
603
|
+
/** Перечитать планы этажей — после правки картографом. */
|
|
604
|
+
refreshIndoor(): void;
|
|
605
|
+
/**
|
|
606
|
+
* Показать найденный объект и открыть его этаж. Ровно то, что нужно после поиска:
|
|
607
|
+
* у объектов внутри зданий приходит `level` — без него карта откроет первый этаж
|
|
608
|
+
* и метка окажется в чужом зале.
|
|
609
|
+
*/
|
|
610
|
+
showPlace(lon: number, lat: number, level?: number | null, zoom?: number): void;
|
|
513
611
|
/** Клик по зданию: { id, height, props } либо null. Повторный вызов заменяет обработчик. */
|
|
514
612
|
onBuildingClick(callback: (info: IMaps3DBuildingClickInfo | null) => void): void;
|
|
515
613
|
/** Выделить здание по osm_id. `false` — здания сейчас нет в загруженных данных. */
|
|
@@ -539,6 +637,23 @@ declare class MahalMap {
|
|
|
539
637
|
* вызов teardown попал бы на уже освобождённый объект.
|
|
540
638
|
*/
|
|
541
639
|
private static teardownMaps3DLayer;
|
|
640
|
+
/**
|
|
641
|
+
* Диагностика неработающего веб-воркера MapLibre.
|
|
642
|
+
*
|
|
643
|
+
* Симптом злой: тайлы приходят, но разобрать их некому — карта показывает пустой фон,
|
|
644
|
+
* а в консоли лежит только `Uncaught SyntaxError: Unexpected token '<'`, где нет ни слова
|
|
645
|
+
* ни про MapLibre, ни про воркер. Причина почти всегда одна: сборщик не перенёс файл
|
|
646
|
+
* воркера рядом со сборкой, и вместо скрипта сервер отдаёт index.html.
|
|
647
|
+
*
|
|
648
|
+
* Проверку вешаем на таймер от создания карты, а НЕ на событие "load": при мёртвом
|
|
649
|
+
* воркере стиль не дозагружается и "load" не приходит вовсе.
|
|
650
|
+
*
|
|
651
|
+
* Смотрим на результат, а не на события: у Maps3D свой сторож (`gn`) слушает
|
|
652
|
+
* `data{sourceDataType:"content"}`, но это событие приходит при регистрации источника,
|
|
653
|
+
* за ~30 мс и без единого тайла — тревога снимается раньше, чем что-то могло сломаться.
|
|
654
|
+
*/
|
|
655
|
+
private watchWorkerHealth;
|
|
656
|
+
private reportBrokenWorker;
|
|
542
657
|
/**
|
|
543
658
|
* Приводит объём зданий к желаемому состоянию. Реестр слоёв (0.7.x) — основная дверь:
|
|
544
659
|
* он же прячет и возвращает штатные здания стиля. setBuildingsEnabled — путь для
|
|
@@ -821,4 +936,4 @@ declare namespace index {
|
|
|
821
936
|
export { index_checkCoordinates as checkCoordinates, index_debounce as debounce, index_geojsonPolyline as geojsonPolyline, index_geometryPolyline as geometryPolyline, index_trimValue as trimValue };
|
|
822
937
|
}
|
|
823
938
|
|
|
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 };
|
|
939
|
+
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as maplibre_gl from 'maplibre-gl';
|
|
1
2
|
import { Map, FlyToOptions, Marker } from 'maplibre-gl';
|
|
2
3
|
|
|
3
4
|
declare class CameraController {
|
|
@@ -26,17 +27,64 @@ interface IAdditionalParamType {
|
|
|
26
27
|
* более старая сборка на странице не ломала типы у потребителя.
|
|
27
28
|
*/
|
|
28
29
|
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
30
|
/** Уровень детализации зданий. */
|
|
32
31
|
type Maps3DBuildingDetail = "footprint" | "volume" | "roofs" | "facade";
|
|
32
|
+
/** Режим рельефа: `auto` показывает его на обзорных зумах, `on` — всегда (дороже по трафику и кадру). */
|
|
33
|
+
type Maps3DTerrainMode = "auto" | "on" | "off";
|
|
34
|
+
/**
|
|
35
|
+
* Параметры каждого слоя реестра. Служит и справочником, и источником типов:
|
|
36
|
+
* ключи дают список id, значения — допустимые `params` в setLayer().
|
|
37
|
+
*
|
|
38
|
+
* У самой Maps3D id слоя типизирован как `string`, поэтому опечатка там проходит
|
|
39
|
+
* компиляцию и проваливается в рантайме (setLayer вернёт false). Здесь список
|
|
40
|
+
* фиксирован по таблице слоёв 0.7.3 — промах ловится на сборке.
|
|
41
|
+
*/
|
|
42
|
+
interface IMaps3DLayerParams {
|
|
43
|
+
/** Объёмные здания. По умолчанию включён. */
|
|
44
|
+
buildings: {
|
|
45
|
+
detail?: Maps3DBuildingDetail;
|
|
46
|
+
};
|
|
47
|
+
/** Расставленные 3D-объекты. По умолчанию включён. */
|
|
48
|
+
objects: Record<string, never>;
|
|
49
|
+
/** Пробки векторным слоем. По умолчанию выключен. */
|
|
50
|
+
traffic: Record<string, never>;
|
|
51
|
+
/** Пробки картинкой с сервера, без клика по дороге. По умолчанию выключен. */
|
|
52
|
+
trafficRaster: Record<string, never>;
|
|
53
|
+
/**
|
|
54
|
+
* Парковки. По умолчанию включён. Подтип берётся из атрибута `fee`:
|
|
55
|
+
* `paid` — `fee=yes`, `free` — `fee=no`, `unknown` — атрибута нет.
|
|
56
|
+
*/
|
|
57
|
+
parking: {
|
|
58
|
+
highlight?: boolean;
|
|
59
|
+
paid?: boolean;
|
|
60
|
+
free?: boolean;
|
|
61
|
+
unknown?: boolean;
|
|
62
|
+
};
|
|
63
|
+
/** Заправки. По умолчанию включён. */
|
|
64
|
+
fuel: Record<string, never>;
|
|
65
|
+
/** Зарядки. По умолчанию включён. */
|
|
66
|
+
charging: Record<string, never>;
|
|
67
|
+
/** Перекрытия дорог. По умолчанию выключен, требует своего тайлсета. */
|
|
68
|
+
closures: Record<string, never>;
|
|
69
|
+
/** Планы этажей. По умолчанию выключен, требует данных по зданию. */
|
|
70
|
+
indoor: {
|
|
71
|
+
level?: number;
|
|
72
|
+
};
|
|
73
|
+
/** Рельеф. По умолчанию `auto`. */
|
|
74
|
+
terrain: {
|
|
75
|
+
mode?: Maps3DTerrainMode;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/** Идентификатор слоя в реестре Maps3D. */
|
|
79
|
+
type Maps3DLayerId = keyof IMaps3DLayerParams;
|
|
33
80
|
/**
|
|
34
81
|
* Снимок состояния слоя. Три поля независимы: слой может быть включён клиентом (`wanted`),
|
|
35
82
|
* но не нарисован — рельеф в режиме auto ждёт обзорного зума, перекрытия ждут своего
|
|
36
83
|
* тайлсета, планы этажей — данных по зданию.
|
|
37
84
|
*/
|
|
38
85
|
interface IMaps3DLayerState {
|
|
39
|
-
|
|
86
|
+
/** Не сужен до Maps3DLayerId: сборка Maps3D может отдать слой, которого нет в нашем списке. */
|
|
87
|
+
id: string;
|
|
40
88
|
/** Чего хочет клиент: последний setLayer либо умолчание стиля. */
|
|
41
89
|
wanted: boolean;
|
|
42
90
|
/** Что позволяет стиль: объявлен ли слой и есть ли под него данные. */
|
|
@@ -150,8 +198,8 @@ interface IMaps3DLayer {
|
|
|
150
198
|
readonly ready?: Promise<void>;
|
|
151
199
|
destroy?(): void;
|
|
152
200
|
remove?(): void;
|
|
153
|
-
setLayer?(id:
|
|
154
|
-
layer?(id:
|
|
201
|
+
setLayer?(id: string, on: boolean, params?: Record<string, unknown>): boolean;
|
|
202
|
+
layer?(id: string): IMaps3DLayerState | null;
|
|
155
203
|
layers?(): IMaps3DLayerState[];
|
|
156
204
|
onLayers?(callback: (state: IMaps3DLayerState) => void): () => void;
|
|
157
205
|
refreshLayers?(): void;
|
|
@@ -216,10 +264,13 @@ type Maps3DCtor = (new (options: IMaps3DLayerOptions) => IMaps3DLayer) & {
|
|
|
216
264
|
styleUrl?(style?: string, base?: string): string;
|
|
217
265
|
/** Подключение к уже созданной карте; возвращает экземпляр с `ready`. */
|
|
218
266
|
enhance?(map: Map, options?: IMaps3DLayerOptions): IMaps3DLayer;
|
|
219
|
-
/**
|
|
267
|
+
/**
|
|
268
|
+
* MapLibre с платформы вместе со своим воркером. Возвращает то же, что
|
|
269
|
+
* `import * as maplibregl from "maplibre-gl"` — декларации гарантирует peerDependency.
|
|
270
|
+
*/
|
|
220
271
|
maplibre?(options?: {
|
|
221
272
|
base?: string;
|
|
222
|
-
}): Promise<
|
|
273
|
+
}): Promise<typeof maplibre_gl>;
|
|
223
274
|
readonly maplibreVersion?: string;
|
|
224
275
|
};
|
|
225
276
|
|
|
@@ -255,6 +306,12 @@ interface IMahalMapOptions {
|
|
|
255
306
|
antialias?: boolean;
|
|
256
307
|
/** Опции Maps3D: buildings, traffic, indoor, closures, terrain, minZoom, lodBias, memoryBudget, ... */
|
|
257
308
|
maps3d?: Omit<IMaps3DLayerOptions, "apiKey" | "base">;
|
|
309
|
+
/**
|
|
310
|
+
* Диагностика неработающего веб-воркера MapLibre: если через 8 с после создания карты
|
|
311
|
+
* не разобран ни один векторный тайл, в консоль уходит предупреждение с причиной и
|
|
312
|
+
* решением. `false` отключает проверку, число задаёт свою задержку в мс.
|
|
313
|
+
*/
|
|
314
|
+
workerCheck?: boolean | number;
|
|
258
315
|
/**
|
|
259
316
|
* @deprecated Игнорируется с 2.0.0. Движок один — платформа MahalMaps через
|
|
260
317
|
* @grammaps/maps3d-web. Без переданного Maps3D карта поднимается на запасном стиле.
|
|
@@ -382,6 +439,8 @@ declare class MahalMap {
|
|
|
382
439
|
private static instances;
|
|
383
440
|
private static defaultLanguage;
|
|
384
441
|
private static disposedMaps3DLayers;
|
|
442
|
+
/** Через сколько мс после создания карты проверяем, ожил ли веб-воркер MapLibre. */
|
|
443
|
+
private static readonly WORKER_CHECK_DELAY;
|
|
385
444
|
private isReady;
|
|
386
445
|
private readyCallbacks;
|
|
387
446
|
private map;
|
|
@@ -400,6 +459,8 @@ declare class MahalMap {
|
|
|
400
459
|
private maps3dLayer?;
|
|
401
460
|
private maps3dReady?;
|
|
402
461
|
private buildingsEnabled;
|
|
462
|
+
private workerCheckTimer?;
|
|
463
|
+
private styleChangeHandler?;
|
|
403
464
|
private constructor();
|
|
404
465
|
private static getInstanceKey;
|
|
405
466
|
private static normalizeLanguage;
|
|
@@ -453,11 +514,15 @@ declare class MahalMap {
|
|
|
453
514
|
static getMaps3DLayer(instance: MahalMap): IMaps3DLayer | undefined;
|
|
454
515
|
static whenMaps3DReady(instance: MahalMap): Promise<IMaps3DLayer | undefined>;
|
|
455
516
|
static toggle3DBuildings(instance: MahalMap, enabled: boolean): void;
|
|
456
|
-
static setLayer(instance: MahalMap, id:
|
|
517
|
+
static setLayer<Id extends Maps3DLayerId>(instance: MahalMap, id: Id, on: boolean, params?: IMaps3DLayerParams[Id]): boolean;
|
|
457
518
|
static getLayerState(instance: MahalMap, id: Maps3DLayerId): IMaps3DLayerState | null;
|
|
458
519
|
static getLayers(instance: MahalMap): IMaps3DLayerState[];
|
|
459
520
|
static onLayers(instance: MahalMap, callback: (state: IMaps3DLayerState) => void): () => void;
|
|
460
521
|
static refreshLayers(instance: MahalMap): void;
|
|
522
|
+
static getIndoorLevels(instance: MahalMap): number[];
|
|
523
|
+
static setIndoorLevel(instance: MahalMap, level: number): void;
|
|
524
|
+
static refreshIndoor(instance: MahalMap): void;
|
|
525
|
+
static showPlace(instance: MahalMap, lon: number, lat: number, level?: number | null, zoom?: number): void;
|
|
461
526
|
static onBuildingClick(instance: MahalMap, callback: (info: IMaps3DBuildingClickInfo | null) => void): void;
|
|
462
527
|
static selectBuilding(instance: MahalMap, id: number | string | null, style?: IMaps3DSelectionStyle): boolean;
|
|
463
528
|
static clearSelection(instance: MahalMap): void;
|
|
@@ -482,7 +547,21 @@ declare class MahalMap {
|
|
|
482
547
|
* Без Maps3D менять нечего — карта на запасном стиле, у него варианта по теме нет.
|
|
483
548
|
*/
|
|
484
549
|
setStyle(theme: Theme): void;
|
|
485
|
-
|
|
550
|
+
/**
|
|
551
|
+
* Адрес стиля по имени темы. mapOptions() — основной контракт (есть с 0.5.0);
|
|
552
|
+
* styleUrl остаётся запасным путём для сборок, где mapOptions ещё нет.
|
|
553
|
+
* Раньше здесь был только styleUrl, и сборка с одним mapOptions() тему не меняла.
|
|
554
|
+
*/
|
|
555
|
+
private resolvePlatformStyle;
|
|
556
|
+
/**
|
|
557
|
+
* Полная смена стиля уносит слои Maps3D вместе с ним — реестр умеет вернуть волю
|
|
558
|
+
* клиента, но только когда новый стиль уже загружен.
|
|
559
|
+
*
|
|
560
|
+
* Слушаем styledata, а не style.load: setStyle() идёт через дифф и style.load при
|
|
561
|
+
* этом не поднимает — с ним восстановление просто не случалось. styledata приходит
|
|
562
|
+
* многократно, поэтому ждём isStyleLoaded() и снимаем обработчик сами.
|
|
563
|
+
*/
|
|
564
|
+
private refreshLayersOnStyleChange;
|
|
486
565
|
/**
|
|
487
566
|
* Язык подписей приходит из стиля платформы, отдельных URL по языкам больше нет —
|
|
488
567
|
* метод только запоминает выбор для остальных сервисов SDK (поиск, роутинг).
|
|
@@ -500,8 +579,15 @@ declare class MahalMap {
|
|
|
500
579
|
* Резолвится в undefined, если слой выключен, Maps3D не передан или подключение упало.
|
|
501
580
|
*/
|
|
502
581
|
whenMaps3DReady(): Promise<IMaps3DLayer | undefined>;
|
|
503
|
-
/**
|
|
504
|
-
|
|
582
|
+
/**
|
|
583
|
+
* Включить/выключить слой. `params` типизирован под конкретный слой: `terrain` ждёт
|
|
584
|
+
* `{ mode }`, `buildings` — `{ detail }`, `indoor` — `{ level }`, у остальных параметров нет.
|
|
585
|
+
*
|
|
586
|
+
* Возвращает `false`, если такого слоя в подключённой сборке Maps3D нет или Maps3D не передан.
|
|
587
|
+
* Слой, которого ещё нет в нашем списке id, доступен напрямую:
|
|
588
|
+
* `map.getMaps3DLayer()?.setLayer?.("новый", true)`.
|
|
589
|
+
*/
|
|
590
|
+
setLayer<Id extends Maps3DLayerId>(id: Id, on: boolean, params?: IMaps3DLayerParams[Id]): boolean;
|
|
505
591
|
/** Состояние слоя: wanted (воля клиента), available (позволяет стиль), active (нарисовано). */
|
|
506
592
|
getLayerState(id: Maps3DLayerId): IMaps3DLayerState | null;
|
|
507
593
|
/** Снимок всех слоёв — по нему приложение рисует свою панель. */
|
|
@@ -510,6 +596,18 @@ declare class MahalMap {
|
|
|
510
596
|
onLayers(callback: (state: IMaps3DLayerState) => void): () => void;
|
|
511
597
|
/** Пере-применить волю клиента ко всем слоям — после полной смены стиля. */
|
|
512
598
|
refreshLayers(): void;
|
|
599
|
+
/** Этажи, найденные в текущем виде карты. Пусто — данных по зданию нет. */
|
|
600
|
+
getIndoorLevels(): number[];
|
|
601
|
+
/** Переключить этаж. Нумерация OSM: 0 — первый наземный. */
|
|
602
|
+
setIndoorLevel(level: number): void;
|
|
603
|
+
/** Перечитать планы этажей — после правки картографом. */
|
|
604
|
+
refreshIndoor(): void;
|
|
605
|
+
/**
|
|
606
|
+
* Показать найденный объект и открыть его этаж. Ровно то, что нужно после поиска:
|
|
607
|
+
* у объектов внутри зданий приходит `level` — без него карта откроет первый этаж
|
|
608
|
+
* и метка окажется в чужом зале.
|
|
609
|
+
*/
|
|
610
|
+
showPlace(lon: number, lat: number, level?: number | null, zoom?: number): void;
|
|
513
611
|
/** Клик по зданию: { id, height, props } либо null. Повторный вызов заменяет обработчик. */
|
|
514
612
|
onBuildingClick(callback: (info: IMaps3DBuildingClickInfo | null) => void): void;
|
|
515
613
|
/** Выделить здание по osm_id. `false` — здания сейчас нет в загруженных данных. */
|
|
@@ -539,6 +637,23 @@ declare class MahalMap {
|
|
|
539
637
|
* вызов teardown попал бы на уже освобождённый объект.
|
|
540
638
|
*/
|
|
541
639
|
private static teardownMaps3DLayer;
|
|
640
|
+
/**
|
|
641
|
+
* Диагностика неработающего веб-воркера MapLibre.
|
|
642
|
+
*
|
|
643
|
+
* Симптом злой: тайлы приходят, но разобрать их некому — карта показывает пустой фон,
|
|
644
|
+
* а в консоли лежит только `Uncaught SyntaxError: Unexpected token '<'`, где нет ни слова
|
|
645
|
+
* ни про MapLibre, ни про воркер. Причина почти всегда одна: сборщик не перенёс файл
|
|
646
|
+
* воркера рядом со сборкой, и вместо скрипта сервер отдаёт index.html.
|
|
647
|
+
*
|
|
648
|
+
* Проверку вешаем на таймер от создания карты, а НЕ на событие "load": при мёртвом
|
|
649
|
+
* воркере стиль не дозагружается и "load" не приходит вовсе.
|
|
650
|
+
*
|
|
651
|
+
* Смотрим на результат, а не на события: у Maps3D свой сторож (`gn`) слушает
|
|
652
|
+
* `data{sourceDataType:"content"}`, но это событие приходит при регистрации источника,
|
|
653
|
+
* за ~30 мс и без единого тайла — тревога снимается раньше, чем что-то могло сломаться.
|
|
654
|
+
*/
|
|
655
|
+
private watchWorkerHealth;
|
|
656
|
+
private reportBrokenWorker;
|
|
542
657
|
/**
|
|
543
658
|
* Приводит объём зданий к желаемому состоянию. Реестр слоёв (0.7.x) — основная дверь:
|
|
544
659
|
* он же прячет и возвращает штатные здания стиля. setBuildingsEnabled — путь для
|
|
@@ -821,4 +936,4 @@ declare namespace index {
|
|
|
821
936
|
export { index_checkCoordinates as checkCoordinates, index_debounce as debounce, index_geojsonPolyline as geojsonPolyline, index_geometryPolyline as geometryPolyline, index_trimValue as trimValue };
|
|
822
937
|
}
|
|
823
938
|
|
|
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 };
|
|
939
|
+
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 };
|