mahal_map 1.6.12 → 1.6.14
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 +73 -0
- package/dist/index.d.mts +49 -3
- package/dist/index.d.ts +49 -3
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/index.mjs.map +1 -1
- package/dist/mahal_map.sdk.js +1 -1
- package/package.json +8 -2
package/README.md
CHANGED
|
@@ -12,6 +12,28 @@ npm install mahal_map maplibre-gl
|
|
|
12
12
|
|
|
13
13
|
`maplibre-gl` является peer dependency. Его нужно установить в приложении или подключить отдельным browser script перед SDK.
|
|
14
14
|
|
|
15
|
+
Для нового 3D-движка (`engine: "3d"`) дополнительно нужен `@osm/maps3d-web`. Пакет **не публикуется в npm** — скачайте его со страницы платформы (кнопка «Web SDK — стартер»; в Vue-стартере это папка `libs/maps3d-web` с уже собранным `dist/`), положите в проект и поставьте как локальную зависимость:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm i ./libs/maps3d-web maplibre-gl
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`package.json` запишет ссылку на локальную папку:
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
"@osm/maps3d-web": "file:./libs/maps3d-web"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Без сборщика возьмите `lib/maps3d.global.js` из скачанного стартера (IIFE-глобал `Maps3D`, three бандлится внутрь) и подключите скриптом после `maplibre-gl`:
|
|
28
|
+
|
|
29
|
+
```html
|
|
30
|
+
<script src="https://cdn.jsdelivr.net/npm/maplibre-gl@4.7.1/dist/maplibre-gl.js"></script>
|
|
31
|
+
<script src="./lib/maps3d.global.js"></script>
|
|
32
|
+
<script src="https://cp.mahal.tj/sdk/mahal_map.sdk.js?apikey=YOUR_MAP_API_KEY"></script>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
SDK сам найдёт конструктор в `window.Maps3D.Maps3D` — передавать его вручную не нужно.
|
|
36
|
+
|
|
15
37
|
## Быстрый старт через NPM
|
|
16
38
|
|
|
17
39
|
```ts
|
|
@@ -100,7 +122,14 @@ interface IMahalMapOptions {
|
|
|
100
122
|
lang?: "tj" | "ru";
|
|
101
123
|
center?: [number, number];
|
|
102
124
|
zoom?: number;
|
|
125
|
+
pitch?: number;
|
|
126
|
+
bearing?: number;
|
|
103
127
|
autoAddVectorSource?: boolean;
|
|
128
|
+
engine?: "legacy" | "3d";
|
|
129
|
+
enable3D?: boolean;
|
|
130
|
+
base?: string;
|
|
131
|
+
preset?: string;
|
|
132
|
+
maps3d?: IMaps3DOptions;
|
|
104
133
|
}
|
|
105
134
|
```
|
|
106
135
|
|
|
@@ -112,7 +141,51 @@ interface IMahalMapOptions {
|
|
|
112
141
|
| `lang` | `"tj" \| "ru"` | Язык стандартного стиля. `tj` оставляет URL только с `token`, `ru` добавляет `lang=ru`. |
|
|
113
142
|
| `center` | `[number, number]` | Центр карты в формате `[lng, lat]`. |
|
|
114
143
|
| `zoom` | `number` | Начальный zoom. |
|
|
144
|
+
| `pitch` | `number` | Начальный наклон камеры (нужен для 3D-вида). |
|
|
145
|
+
| `bearing` | `number` | Начальный поворот камеры. |
|
|
115
146
|
| `autoAddVectorSource` | `boolean` | Использует встроенный vector style и блокирует смену стандартного стиля через `setStyle`. |
|
|
147
|
+
| `engine` | `"legacy" \| "3d"` | Переключатель движка карты. `"legacy"` (по умолчанию) — старые стили mtile.gram.tj. `"3d"` — новая платформа GramMaps (route.gram.tj) с пресетами стиля и Maps3D. |
|
|
148
|
+
| `enable3D` | `boolean` | Подключает детальные 3D-здания (Maps3D). Работает только при `engine: "3d"`. |
|
|
149
|
+
| `base` | `string` | Домен платформы GramMaps для `engine: "3d"`. По умолчанию `https://route.gram.tj`. |
|
|
150
|
+
| `preset` | `string` | Имя пресета стиля GramMaps (напр. `"standard-night"`) для `engine: "3d"`. По умолчанию `standard-day`/`standard-night` в зависимости от `theme`. |
|
|
151
|
+
| `maps3d` | `object` | Доп. опции Maps3D слоя: `traffic`, `minZoom`, `lodBias`, `memoryBudget`, `maskReplaced`, `typeReplacements`. |
|
|
152
|
+
|
|
153
|
+
### Новый 3D-движок (GramMaps / Maps3D)
|
|
154
|
+
|
|
155
|
+
Токен передается как обычно, через `keyUtils.saveKey()` — отдельно ключ для Maps3D передавать не нужно.
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
import maplibregl from "maplibre-gl";
|
|
159
|
+
import "maplibre-gl/dist/maplibre-gl.css";
|
|
160
|
+
import { Maps3D } from "@osm/maps3d-web";
|
|
161
|
+
import { MahalMap, keyUtils } from "mahal_map";
|
|
162
|
+
|
|
163
|
+
keyUtils.saveKey("YOUR_MAP_API_KEY");
|
|
164
|
+
|
|
165
|
+
const map = MahalMap.create(
|
|
166
|
+
{
|
|
167
|
+
container: "map",
|
|
168
|
+
center: [68.78, 38.56],
|
|
169
|
+
zoom: 16.6,
|
|
170
|
+
pitch: 58,
|
|
171
|
+
theme: "dark",
|
|
172
|
+
engine: "3d",
|
|
173
|
+
enable3D: true,
|
|
174
|
+
},
|
|
175
|
+
maplibregl,
|
|
176
|
+
Maps3D,
|
|
177
|
+
);
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
`Maps3D` (третий аргумент `create()`) — опционален: если не передан, SDK попробует взять его из `window.Maps3D`. `@osm/maps3d-web` — необязательный peer dependency, ставится только если используется `engine: "3d"`.
|
|
181
|
+
|
|
182
|
+
Получить слой Maps3D после создания карты:
|
|
183
|
+
|
|
184
|
+
```ts
|
|
185
|
+
const layer = map.getMaps3DLayer();
|
|
186
|
+
// или
|
|
187
|
+
MahalMap.getMaps3DLayer(map);
|
|
188
|
+
```
|
|
116
189
|
|
|
117
190
|
## MahalMap
|
|
118
191
|
|
package/dist/index.d.mts
CHANGED
|
@@ -19,6 +19,31 @@ interface IAdditionalParamType {
|
|
|
19
19
|
limit?: number;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
interface IMaps3DLayerOptions {
|
|
23
|
+
apiKey?: string | null;
|
|
24
|
+
base?: string;
|
|
25
|
+
buildings?: boolean | Record<string, unknown>;
|
|
26
|
+
traffic?: boolean | Record<string, unknown>;
|
|
27
|
+
minZoom?: number;
|
|
28
|
+
lodBias?: number;
|
|
29
|
+
memoryBudget?: number;
|
|
30
|
+
maskReplaced?: boolean;
|
|
31
|
+
typeReplacements?: boolean;
|
|
32
|
+
}
|
|
33
|
+
interface IMaps3DLayer {
|
|
34
|
+
attach(map: Map): void;
|
|
35
|
+
destroy?(): void;
|
|
36
|
+
remove?(): void;
|
|
37
|
+
}
|
|
38
|
+
interface IMaps3DTransformRequestOptions {
|
|
39
|
+
base: string;
|
|
40
|
+
apiKey?: string | null;
|
|
41
|
+
}
|
|
42
|
+
type Maps3DTransformRequest = (options: IMaps3DTransformRequestOptions) => unknown;
|
|
43
|
+
type Maps3DCtor = (new (options: IMaps3DLayerOptions) => IMaps3DLayer) & {
|
|
44
|
+
transformRequest: Maps3DTransformRequest;
|
|
45
|
+
};
|
|
46
|
+
|
|
22
47
|
interface IMahalMapOptions {
|
|
23
48
|
container?: string | HTMLElement;
|
|
24
49
|
style?: string;
|
|
@@ -26,10 +51,23 @@ interface IMahalMapOptions {
|
|
|
26
51
|
lang?: MapLanguage;
|
|
27
52
|
center?: [number, number];
|
|
28
53
|
zoom?: number;
|
|
54
|
+
pitch?: number;
|
|
55
|
+
bearing?: number;
|
|
29
56
|
autoAddVectorSource?: boolean;
|
|
57
|
+
/** "legacy" (default) — старый движок (mtile.gram.tj). "3d" — новый GramMaps движок (route.gram.tj) с поддержкой Maps3D. */
|
|
58
|
+
engine?: MapEngine;
|
|
59
|
+
/** Включает Maps3D слой (детальные 3D-здания). Работает только при engine: "3d". */
|
|
60
|
+
enable3D?: boolean;
|
|
61
|
+
/** Домен платформы GramMaps для engine: "3d". По умолчанию https://route.gram.tj */
|
|
62
|
+
base?: string;
|
|
63
|
+
/** Имя пресета стиля GramMaps (напр. "standard-night") для engine: "3d". */
|
|
64
|
+
preset?: string;
|
|
65
|
+
/** Доп. опции Maps3D слоя (buildings, traffic, minZoom, lodBias, memoryBudget, ...). */
|
|
66
|
+
maps3d?: Omit<IMaps3DLayerOptions, "apiKey" | "base" | "buildings">;
|
|
30
67
|
}
|
|
31
68
|
type Theme = "dark" | "light";
|
|
32
69
|
type MapLanguage = "tj" | "ru";
|
|
70
|
+
type MapEngine = "legacy" | "3d";
|
|
33
71
|
|
|
34
72
|
interface MahalMapDefaultMarkerProps {
|
|
35
73
|
coordinates: [number, number];
|
|
@@ -144,6 +182,12 @@ declare class MahalMap {
|
|
|
144
182
|
private options;
|
|
145
183
|
private language;
|
|
146
184
|
private instanceKey;
|
|
185
|
+
private engine;
|
|
186
|
+
private gramBase;
|
|
187
|
+
private gramPreset;
|
|
188
|
+
private presetIsExplicit;
|
|
189
|
+
private maps3dCtor?;
|
|
190
|
+
private maps3dLayer?;
|
|
147
191
|
private constructor();
|
|
148
192
|
private static getInstanceKey;
|
|
149
193
|
private static normalizeLanguage;
|
|
@@ -151,7 +195,8 @@ declare class MahalMap {
|
|
|
151
195
|
private static getDefaultStyle;
|
|
152
196
|
private static getVectorStyle;
|
|
153
197
|
private static getMapToken;
|
|
154
|
-
static
|
|
198
|
+
private static getMaps3DCtor;
|
|
199
|
+
static create(options: IMahalMapOptions, maplibreObject?: MapLibreApi, maps3dCtor?: Maps3DCtor): MahalMap;
|
|
155
200
|
static onReady(container: string, callback: (map: Map) => void): void;
|
|
156
201
|
static getInstance(container: string): MahalMap;
|
|
157
202
|
static hasInstance(container: string): boolean;
|
|
@@ -160,6 +205,7 @@ declare class MahalMap {
|
|
|
160
205
|
static getCamera(instance: MahalMap): CameraController;
|
|
161
206
|
static getMap(instance: MahalMap): Map;
|
|
162
207
|
static setStyle(instance: MahalMap, theme: Theme): void;
|
|
208
|
+
static getMaps3DLayer(instance: MahalMap): IMaps3DLayer | undefined;
|
|
163
209
|
static setLanguage(instance: MahalMap, lang: MapLanguage): void;
|
|
164
210
|
static setCenter(instance: MahalMap, center: [number, number]): void;
|
|
165
211
|
static setZoom(instance: MahalMap, zoom: number): void;
|
|
@@ -170,6 +216,7 @@ declare class MahalMap {
|
|
|
170
216
|
getMap(): Map;
|
|
171
217
|
setStyle(theme: Theme): void;
|
|
172
218
|
setLanguage(lang: MapLanguage): void;
|
|
219
|
+
getMaps3DLayer(): IMaps3DLayer | undefined;
|
|
173
220
|
setCenter(center: [number, number]): void;
|
|
174
221
|
setZoom(zoom: number): void;
|
|
175
222
|
destroy(): void;
|
|
@@ -349,7 +396,6 @@ declare class MeasureTool {
|
|
|
349
396
|
private setCursor;
|
|
350
397
|
private onStyleLoad;
|
|
351
398
|
private emitChange;
|
|
352
|
-
private tryEnsureLayers;
|
|
353
399
|
private ensureLayers;
|
|
354
400
|
private removeLayers;
|
|
355
401
|
private setSourceData;
|
|
@@ -426,4 +472,4 @@ declare namespace index {
|
|
|
426
472
|
export { index_checkCoordinates as checkCoordinates, index_debounce as debounce, index_geojsonPolyline as geojsonPolyline, index_geometryPolyline as geometryPolyline, index_trimValue as trimValue };
|
|
427
473
|
}
|
|
428
474
|
|
|
429
|
-
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 };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -19,6 +19,31 @@ interface IAdditionalParamType {
|
|
|
19
19
|
limit?: number;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
interface IMaps3DLayerOptions {
|
|
23
|
+
apiKey?: string | null;
|
|
24
|
+
base?: string;
|
|
25
|
+
buildings?: boolean | Record<string, unknown>;
|
|
26
|
+
traffic?: boolean | Record<string, unknown>;
|
|
27
|
+
minZoom?: number;
|
|
28
|
+
lodBias?: number;
|
|
29
|
+
memoryBudget?: number;
|
|
30
|
+
maskReplaced?: boolean;
|
|
31
|
+
typeReplacements?: boolean;
|
|
32
|
+
}
|
|
33
|
+
interface IMaps3DLayer {
|
|
34
|
+
attach(map: Map): void;
|
|
35
|
+
destroy?(): void;
|
|
36
|
+
remove?(): void;
|
|
37
|
+
}
|
|
38
|
+
interface IMaps3DTransformRequestOptions {
|
|
39
|
+
base: string;
|
|
40
|
+
apiKey?: string | null;
|
|
41
|
+
}
|
|
42
|
+
type Maps3DTransformRequest = (options: IMaps3DTransformRequestOptions) => unknown;
|
|
43
|
+
type Maps3DCtor = (new (options: IMaps3DLayerOptions) => IMaps3DLayer) & {
|
|
44
|
+
transformRequest: Maps3DTransformRequest;
|
|
45
|
+
};
|
|
46
|
+
|
|
22
47
|
interface IMahalMapOptions {
|
|
23
48
|
container?: string | HTMLElement;
|
|
24
49
|
style?: string;
|
|
@@ -26,10 +51,23 @@ interface IMahalMapOptions {
|
|
|
26
51
|
lang?: MapLanguage;
|
|
27
52
|
center?: [number, number];
|
|
28
53
|
zoom?: number;
|
|
54
|
+
pitch?: number;
|
|
55
|
+
bearing?: number;
|
|
29
56
|
autoAddVectorSource?: boolean;
|
|
57
|
+
/** "legacy" (default) — старый движок (mtile.gram.tj). "3d" — новый GramMaps движок (route.gram.tj) с поддержкой Maps3D. */
|
|
58
|
+
engine?: MapEngine;
|
|
59
|
+
/** Включает Maps3D слой (детальные 3D-здания). Работает только при engine: "3d". */
|
|
60
|
+
enable3D?: boolean;
|
|
61
|
+
/** Домен платформы GramMaps для engine: "3d". По умолчанию https://route.gram.tj */
|
|
62
|
+
base?: string;
|
|
63
|
+
/** Имя пресета стиля GramMaps (напр. "standard-night") для engine: "3d". */
|
|
64
|
+
preset?: string;
|
|
65
|
+
/** Доп. опции Maps3D слоя (buildings, traffic, minZoom, lodBias, memoryBudget, ...). */
|
|
66
|
+
maps3d?: Omit<IMaps3DLayerOptions, "apiKey" | "base" | "buildings">;
|
|
30
67
|
}
|
|
31
68
|
type Theme = "dark" | "light";
|
|
32
69
|
type MapLanguage = "tj" | "ru";
|
|
70
|
+
type MapEngine = "legacy" | "3d";
|
|
33
71
|
|
|
34
72
|
interface MahalMapDefaultMarkerProps {
|
|
35
73
|
coordinates: [number, number];
|
|
@@ -144,6 +182,12 @@ declare class MahalMap {
|
|
|
144
182
|
private options;
|
|
145
183
|
private language;
|
|
146
184
|
private instanceKey;
|
|
185
|
+
private engine;
|
|
186
|
+
private gramBase;
|
|
187
|
+
private gramPreset;
|
|
188
|
+
private presetIsExplicit;
|
|
189
|
+
private maps3dCtor?;
|
|
190
|
+
private maps3dLayer?;
|
|
147
191
|
private constructor();
|
|
148
192
|
private static getInstanceKey;
|
|
149
193
|
private static normalizeLanguage;
|
|
@@ -151,7 +195,8 @@ declare class MahalMap {
|
|
|
151
195
|
private static getDefaultStyle;
|
|
152
196
|
private static getVectorStyle;
|
|
153
197
|
private static getMapToken;
|
|
154
|
-
static
|
|
198
|
+
private static getMaps3DCtor;
|
|
199
|
+
static create(options: IMahalMapOptions, maplibreObject?: MapLibreApi, maps3dCtor?: Maps3DCtor): MahalMap;
|
|
155
200
|
static onReady(container: string, callback: (map: Map) => void): void;
|
|
156
201
|
static getInstance(container: string): MahalMap;
|
|
157
202
|
static hasInstance(container: string): boolean;
|
|
@@ -160,6 +205,7 @@ declare class MahalMap {
|
|
|
160
205
|
static getCamera(instance: MahalMap): CameraController;
|
|
161
206
|
static getMap(instance: MahalMap): Map;
|
|
162
207
|
static setStyle(instance: MahalMap, theme: Theme): void;
|
|
208
|
+
static getMaps3DLayer(instance: MahalMap): IMaps3DLayer | undefined;
|
|
163
209
|
static setLanguage(instance: MahalMap, lang: MapLanguage): void;
|
|
164
210
|
static setCenter(instance: MahalMap, center: [number, number]): void;
|
|
165
211
|
static setZoom(instance: MahalMap, zoom: number): void;
|
|
@@ -170,6 +216,7 @@ declare class MahalMap {
|
|
|
170
216
|
getMap(): Map;
|
|
171
217
|
setStyle(theme: Theme): void;
|
|
172
218
|
setLanguage(lang: MapLanguage): void;
|
|
219
|
+
getMaps3DLayer(): IMaps3DLayer | undefined;
|
|
173
220
|
setCenter(center: [number, number]): void;
|
|
174
221
|
setZoom(zoom: number): void;
|
|
175
222
|
destroy(): void;
|
|
@@ -349,7 +396,6 @@ declare class MeasureTool {
|
|
|
349
396
|
private setCursor;
|
|
350
397
|
private onStyleLoad;
|
|
351
398
|
private emitChange;
|
|
352
|
-
private tryEnsureLayers;
|
|
353
399
|
private ensureLayers;
|
|
354
400
|
private removeLayers;
|
|
355
401
|
private setSourceData;
|
|
@@ -426,4 +472,4 @@ declare namespace index {
|
|
|
426
472
|
export { index_checkCoordinates as checkCoordinates, index_debounce as debounce, index_geojsonPolyline as geojsonPolyline, index_geometryPolyline as geometryPolyline, index_trimValue as trimValue };
|
|
427
473
|
}
|
|
428
474
|
|
|
429
|
-
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 };
|
|
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 };
|