mahal_map 1.6.14 → 1.6.16
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 +74 -3
- package/dist/index.d.mts +45 -3
- package/dist/index.d.ts +45 -3
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/mahal_map.sdk.js +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -144,10 +144,10 @@ interface IMahalMapOptions {
|
|
|
144
144
|
| `pitch` | `number` | Начальный наклон камеры (нужен для 3D-вида). |
|
|
145
145
|
| `bearing` | `number` | Начальный поворот камеры. |
|
|
146
146
|
| `autoAddVectorSource` | `boolean` | Использует встроенный vector style и блокирует смену стандартного стиля через `setStyle`. |
|
|
147
|
-
| `engine` | `"legacy" \| "3d"` | Переключатель движка карты. `"legacy"` (по умолчанию) — старые стили mtile.gram.tj. `"3d"` — новая платформа GramMaps (
|
|
147
|
+
| `engine` | `"legacy" \| "3d"` | Переключатель движка карты. `"legacy"` (по умолчанию) — старые стили mtile.gram.tj. `"3d"` — новая платформа GramMaps (navi.gram.tj) с пресетами стиля и Maps3D. |
|
|
148
148
|
| `enable3D` | `boolean` | Подключает детальные 3D-здания (Maps3D). Работает только при `engine: "3d"`. |
|
|
149
|
-
| `base` | `string` | Домен платформы GramMaps для `engine: "3d"`. По умолчанию `https://
|
|
150
|
-
| `preset` | `string` | Имя пресета стиля GramMaps (напр. `"standard-night"`) для `engine: "3d"`. По умолчанию `
|
|
149
|
+
| `base` | `string` | Домен платформы GramMaps для `engine: "3d"`. По умолчанию `https://navi.gram.tj`. |
|
|
150
|
+
| `preset` | `string` | Имя пресета стиля GramMaps (напр. `"standard-night"`) для `engine: "3d"`. По умолчанию `road-urban-lab-v2`/`standard-night` в зависимости от `theme`. |
|
|
151
151
|
| `maps3d` | `object` | Доп. опции Maps3D слоя: `traffic`, `minZoom`, `lodBias`, `memoryBudget`, `maskReplaced`, `typeReplacements`. |
|
|
152
152
|
|
|
153
153
|
### Новый 3D-движок (GramMaps / Maps3D)
|
|
@@ -187,6 +187,77 @@ const layer = map.getMaps3DLayer();
|
|
|
187
187
|
MahalMap.getMaps3DLayer(map);
|
|
188
188
|
```
|
|
189
189
|
|
|
190
|
+
`getMaps3DLayer()` возвращает реальный инстанс `Maps3D` (не обёртку) — типы `mahal_map` описывают всю его публичную поверхность, так что подключающему сервису не нужно ставить или типизировать `@osm/maps3d-web` отдельно.
|
|
191
|
+
|
|
192
|
+
### Опции `maps3d` (расширенные)
|
|
193
|
+
|
|
194
|
+
Передаются в `MahalMap.create({ maps3d: {...} })` при `engine: "3d"`:
|
|
195
|
+
|
|
196
|
+
| Опция | Тип | По умолч. | Описание |
|
|
197
|
+
| --- | --- | --- | --- |
|
|
198
|
+
| `traffic` | `boolean \| { raster?, rasterMaxZoom?, graph? }` | `false` | Слой пробок. `raster: true` — картинкой с сервера вместо векторного слоя. |
|
|
199
|
+
| `minZoom` | `number` | `16` | Зум появления детальных 3D. |
|
|
200
|
+
| `lodBias` | `number` | `1` | `0` — всегда lod0 (детальный), `1` — lod1 на дальних зумах. |
|
|
201
|
+
| `memoryBudget` | `number` | `30` | Сколько моделей держать в сцене одновременно. |
|
|
202
|
+
| `maskReplaced` | `boolean` | `true` | Прятать заменённые OSM-объекты (`anchor=replace`). |
|
|
203
|
+
| `typeReplacements` | `boolean` | `true` | Рисовать замены по типу (`natural=tree` → 3D-дерево и т.п.). |
|
|
204
|
+
|
|
205
|
+
`buildings: true` включается автоматически при `enable3D: true` — переопределять не нужно, если только не требуется передать сам объект опций.
|
|
206
|
+
|
|
207
|
+
### 3D-здания
|
|
208
|
+
|
|
209
|
+
Тема (окна/свет) приходит из `metadata` пресета стиля и применяется автоматически при `map.setStyle()` — пересоздавать слой не нужно. Ручные сеттеры перебивают её:
|
|
210
|
+
|
|
211
|
+
```ts
|
|
212
|
+
const layer = map.getMaps3DLayer();
|
|
213
|
+
|
|
214
|
+
layer?.setBuildingsEnabled(false); // 3D-здания ⇄ штатные здания стиля
|
|
215
|
+
|
|
216
|
+
const b = layer?.buildings;
|
|
217
|
+
b?.setWindowStyle(7); // тип окна 0..9 (сетка, лента, curtain wall, ...)
|
|
218
|
+
b?.setWindowDepth(0.85);
|
|
219
|
+
b?.setWindowColor("#6b9ed1");
|
|
220
|
+
b?.setWindowFrameColor("#f2f2f4");
|
|
221
|
+
b?.setEdgeRadius(1.2);
|
|
222
|
+
b?.setSunIntensity(3.2);
|
|
223
|
+
b?.setAmbient(0.76);
|
|
224
|
+
b?.setSky(0.91);
|
|
225
|
+
b?.setExposure(1.5);
|
|
226
|
+
|
|
227
|
+
layer?.onBuildingClick((info) => {
|
|
228
|
+
if (!info) return;
|
|
229
|
+
console.log(info.id, info.height, info.props);
|
|
230
|
+
});
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Пробки
|
|
234
|
+
|
|
235
|
+
```ts
|
|
236
|
+
const layer = map.getMaps3DLayer();
|
|
237
|
+
|
|
238
|
+
layer?.setTraffic(true);
|
|
239
|
+
layer?.setTrafficOpacity(0.85);
|
|
240
|
+
layer?.setTrafficClicks(true); // попап скорости по клику
|
|
241
|
+
layer?.refreshTraffic();
|
|
242
|
+
|
|
243
|
+
// растровый вариант (картинка с сервера, без клика по дороге)
|
|
244
|
+
layer?.setTrafficRaster(true);
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### Жизненный цикл слоя
|
|
248
|
+
|
|
249
|
+
```ts
|
|
250
|
+
const layer = map.getMaps3DLayer();
|
|
251
|
+
|
|
252
|
+
layer?.setMinZoom(15);
|
|
253
|
+
layer?.setObjectsLight({ sun: 1.8, ambient: 0.45, sky: 1.1, exposure: 1.15 });
|
|
254
|
+
await layer?.refresh(); // перечитать модели после правок
|
|
255
|
+
await layer?.clearCache(); // сбросить IndexedDB-кеш ассетов
|
|
256
|
+
layer?.destroy?.(); // отцепить слой (также вызывается автоматически в map.destroy())
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
`map.destroy()` / `MahalMap.destroy(map)` сами вызывают `destroy()`/`remove()` у Maps3D слоя, если он был подключен — отдельно чистить не нужно.
|
|
260
|
+
|
|
190
261
|
## MahalMap
|
|
191
262
|
|
|
192
263
|
`MahalMap` - основной класс карты. Конструктор закрыт, карту нужно создавать через `MahalMap.create()`.
|
package/dist/index.d.mts
CHANGED
|
@@ -19,21 +19,63 @@ interface IAdditionalParamType {
|
|
|
19
19
|
limit?: number;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
interface IMaps3DTrafficOptions {
|
|
23
|
+
raster?: boolean;
|
|
24
|
+
rasterMaxZoom?: number;
|
|
25
|
+
graph?: string;
|
|
26
|
+
}
|
|
22
27
|
interface IMaps3DLayerOptions {
|
|
23
28
|
apiKey?: string | null;
|
|
24
29
|
base?: string;
|
|
25
30
|
buildings?: boolean | Record<string, unknown>;
|
|
26
|
-
traffic?: boolean |
|
|
31
|
+
traffic?: boolean | IMaps3DTrafficOptions;
|
|
27
32
|
minZoom?: number;
|
|
28
33
|
lodBias?: number;
|
|
29
34
|
memoryBudget?: number;
|
|
30
35
|
maskReplaced?: boolean;
|
|
31
36
|
typeReplacements?: boolean;
|
|
32
37
|
}
|
|
38
|
+
interface IMaps3DBuildingsController {
|
|
39
|
+
setWindowStyle(style: number): void;
|
|
40
|
+
setWindowDepth(depth: number): void;
|
|
41
|
+
setWindowColor(color: string): void;
|
|
42
|
+
setWindowFrameColor(color: string): void;
|
|
43
|
+
setEdgeRadius(radius: number): void;
|
|
44
|
+
setSunIntensity(value: number): void;
|
|
45
|
+
setAmbient(value: number): void;
|
|
46
|
+
setSky(value: number): void;
|
|
47
|
+
setExposure(value: number): void;
|
|
48
|
+
}
|
|
49
|
+
interface IMaps3DBuildingClickInfo {
|
|
50
|
+
id: string | number;
|
|
51
|
+
height?: number;
|
|
52
|
+
props?: Record<string, unknown>;
|
|
53
|
+
[key: string]: unknown;
|
|
54
|
+
}
|
|
55
|
+
interface IMaps3DObjectsLightOptions {
|
|
56
|
+
sun?: number;
|
|
57
|
+
ambient?: number;
|
|
58
|
+
sky?: number;
|
|
59
|
+
exposure?: number;
|
|
60
|
+
}
|
|
33
61
|
interface IMaps3DLayer {
|
|
34
|
-
attach(map: Map): void
|
|
62
|
+
attach(map: Map): void | Promise<void>;
|
|
35
63
|
destroy?(): void;
|
|
36
64
|
remove?(): void;
|
|
65
|
+
buildings?: IMaps3DBuildingsController;
|
|
66
|
+
setBuildingsEnabled?(enabled: boolean): void;
|
|
67
|
+
onBuildingClick?(callback: (info: IMaps3DBuildingClickInfo | null) => void): void;
|
|
68
|
+
traffic?: boolean;
|
|
69
|
+
trafficRaster?: boolean;
|
|
70
|
+
setTraffic?(enabled: boolean): void;
|
|
71
|
+
setTrafficOpacity?(opacity: number): void;
|
|
72
|
+
setTrafficClicks?(enabled: boolean): void;
|
|
73
|
+
setTrafficRaster?(enabled: boolean): void;
|
|
74
|
+
refreshTraffic?(): void;
|
|
75
|
+
setObjectsLight?(options: IMaps3DObjectsLightOptions): void;
|
|
76
|
+
setMinZoom?(zoom: number): void;
|
|
77
|
+
refresh?(): Promise<void>;
|
|
78
|
+
clearCache?(): Promise<void>;
|
|
37
79
|
}
|
|
38
80
|
interface IMaps3DTransformRequestOptions {
|
|
39
81
|
base: string;
|
|
@@ -472,4 +514,4 @@ declare namespace index {
|
|
|
472
514
|
export { index_checkCoordinates as checkCoordinates, index_debounce as debounce, index_geojsonPolyline as geojsonPolyline, index_geometryPolyline as geometryPolyline, index_trimValue as trimValue };
|
|
473
515
|
}
|
|
474
516
|
|
|
475
|
-
export { type IAdditionalParamType, type IMahalMapOptions, type IMapMarker, type IMaps3DLayer, type IMaps3DLayerOptions, type IResponse, type IRoute, type ISearchByLocationParam, type ISearchParam, type ISearchResponse, MahalMap, MahalMapDefaultMarker, type MahalMapDefaultMarkerProps, type MapEngine, type MapLanguage, type Maps3DCtor, type Maps3DTransformRequest, 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 };
|
|
517
|
+
export { type IAdditionalParamType, type IMahalMapOptions, type IMapMarker, type IMaps3DBuildingClickInfo, type IMaps3DBuildingsController, type IMaps3DLayer, type IMaps3DLayerOptions, type IMaps3DObjectsLightOptions, type IMaps3DTrafficOptions, type IResponse, type IRoute, type ISearchByLocationParam, type ISearchParam, type ISearchResponse, MahalMap, MahalMapDefaultMarker, type MahalMapDefaultMarkerProps, type MapEngine, type MapLanguage, type Maps3DCtor, type Maps3DTransformRequest, 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
|
@@ -19,21 +19,63 @@ interface IAdditionalParamType {
|
|
|
19
19
|
limit?: number;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
interface IMaps3DTrafficOptions {
|
|
23
|
+
raster?: boolean;
|
|
24
|
+
rasterMaxZoom?: number;
|
|
25
|
+
graph?: string;
|
|
26
|
+
}
|
|
22
27
|
interface IMaps3DLayerOptions {
|
|
23
28
|
apiKey?: string | null;
|
|
24
29
|
base?: string;
|
|
25
30
|
buildings?: boolean | Record<string, unknown>;
|
|
26
|
-
traffic?: boolean |
|
|
31
|
+
traffic?: boolean | IMaps3DTrafficOptions;
|
|
27
32
|
minZoom?: number;
|
|
28
33
|
lodBias?: number;
|
|
29
34
|
memoryBudget?: number;
|
|
30
35
|
maskReplaced?: boolean;
|
|
31
36
|
typeReplacements?: boolean;
|
|
32
37
|
}
|
|
38
|
+
interface IMaps3DBuildingsController {
|
|
39
|
+
setWindowStyle(style: number): void;
|
|
40
|
+
setWindowDepth(depth: number): void;
|
|
41
|
+
setWindowColor(color: string): void;
|
|
42
|
+
setWindowFrameColor(color: string): void;
|
|
43
|
+
setEdgeRadius(radius: number): void;
|
|
44
|
+
setSunIntensity(value: number): void;
|
|
45
|
+
setAmbient(value: number): void;
|
|
46
|
+
setSky(value: number): void;
|
|
47
|
+
setExposure(value: number): void;
|
|
48
|
+
}
|
|
49
|
+
interface IMaps3DBuildingClickInfo {
|
|
50
|
+
id: string | number;
|
|
51
|
+
height?: number;
|
|
52
|
+
props?: Record<string, unknown>;
|
|
53
|
+
[key: string]: unknown;
|
|
54
|
+
}
|
|
55
|
+
interface IMaps3DObjectsLightOptions {
|
|
56
|
+
sun?: number;
|
|
57
|
+
ambient?: number;
|
|
58
|
+
sky?: number;
|
|
59
|
+
exposure?: number;
|
|
60
|
+
}
|
|
33
61
|
interface IMaps3DLayer {
|
|
34
|
-
attach(map: Map): void
|
|
62
|
+
attach(map: Map): void | Promise<void>;
|
|
35
63
|
destroy?(): void;
|
|
36
64
|
remove?(): void;
|
|
65
|
+
buildings?: IMaps3DBuildingsController;
|
|
66
|
+
setBuildingsEnabled?(enabled: boolean): void;
|
|
67
|
+
onBuildingClick?(callback: (info: IMaps3DBuildingClickInfo | null) => void): void;
|
|
68
|
+
traffic?: boolean;
|
|
69
|
+
trafficRaster?: boolean;
|
|
70
|
+
setTraffic?(enabled: boolean): void;
|
|
71
|
+
setTrafficOpacity?(opacity: number): void;
|
|
72
|
+
setTrafficClicks?(enabled: boolean): void;
|
|
73
|
+
setTrafficRaster?(enabled: boolean): void;
|
|
74
|
+
refreshTraffic?(): void;
|
|
75
|
+
setObjectsLight?(options: IMaps3DObjectsLightOptions): void;
|
|
76
|
+
setMinZoom?(zoom: number): void;
|
|
77
|
+
refresh?(): Promise<void>;
|
|
78
|
+
clearCache?(): Promise<void>;
|
|
37
79
|
}
|
|
38
80
|
interface IMaps3DTransformRequestOptions {
|
|
39
81
|
base: string;
|
|
@@ -472,4 +514,4 @@ declare namespace index {
|
|
|
472
514
|
export { index_checkCoordinates as checkCoordinates, index_debounce as debounce, index_geojsonPolyline as geojsonPolyline, index_geometryPolyline as geometryPolyline, index_trimValue as trimValue };
|
|
473
515
|
}
|
|
474
516
|
|
|
475
|
-
export { type IAdditionalParamType, type IMahalMapOptions, type IMapMarker, type IMaps3DLayer, type IMaps3DLayerOptions, type IResponse, type IRoute, type ISearchByLocationParam, type ISearchParam, type ISearchResponse, MahalMap, MahalMapDefaultMarker, type MahalMapDefaultMarkerProps, type MapEngine, type MapLanguage, type Maps3DCtor, type Maps3DTransformRequest, 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 };
|
|
517
|
+
export { type IAdditionalParamType, type IMahalMapOptions, type IMapMarker, type IMaps3DBuildingClickInfo, type IMaps3DBuildingsController, type IMaps3DLayer, type IMaps3DLayerOptions, type IMaps3DObjectsLightOptions, type IMaps3DTrafficOptions, type IResponse, type IRoute, type ISearchByLocationParam, type ISearchParam, type ISearchResponse, MahalMap, MahalMapDefaultMarker, type MahalMapDefaultMarkerProps, type MapEngine, type MapLanguage, type Maps3DCtor, type Maps3DTransformRequest, 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 };
|