@mappable-world/mappable-types 0.0.21 → 0.0.15085412

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.
Files changed (38) hide show
  1. package/common/types/data-source-description.d.ts +8 -0
  2. package/imperative/DomContext.d.ts +2 -2
  3. package/imperative/MMap/index.d.ts +77 -7
  4. package/imperative/MMap/projection.d.ts +1 -1
  5. package/imperative/MMapCollection/index.d.ts +18 -0
  6. package/imperative/MMapContainer/index.d.ts +14 -0
  7. package/imperative/MMapContextProvider/index.d.ts +28 -3
  8. package/imperative/MMapControl/MMapControlButton.d.ts +25 -2
  9. package/imperative/MMapCopyrights/index.d.ts +15 -16
  10. package/imperative/MMapDefaultSchemeLayer/index.d.ts +11 -3
  11. package/imperative/MMapEnities.d.ts +48 -1
  12. package/imperative/MMapFeature/index.d.ts +16 -2
  13. package/imperative/MMapFeature/types.d.ts +15 -0
  14. package/imperative/MMapHotspot/index.d.ts +14 -0
  15. package/imperative/MMapReactContainer/index.d.ts +12 -3
  16. package/imperative/MMapScaleControl/index.d.ts +22 -0
  17. package/imperative/MMapTileDataSource/index.d.ts +3 -3
  18. package/imperative/ThemeContext.d.ts +7 -1
  19. package/imperative/TypeContext.d.ts +3 -0
  20. package/imperative/config.d.ts +25 -0
  21. package/imperative/index.d.ts +1 -1
  22. package/imperative/{utils/projections → projections}/web-mercator.d.ts +5 -7
  23. package/package.json +31 -18
  24. package/packages/hint/MMapHint/index.d.ts +1 -1
  25. package/imperative/MMapCoverage/index.d.ts +0 -55
  26. package/imperative/utils/allowed-custom-layer-implementations.d.ts +0 -1
  27. package/imperative/utils/deepFreeze.d.ts +0 -2
  28. package/imperative/utils/errorLogger.d.ts +0 -29
  29. package/imperative/utils/id.d.ts +0 -2
  30. package/imperative/utils/index.d.ts +0 -3
  31. package/imperative/utils/jsonp.d.ts +0 -9
  32. package/imperative/utils/metrics.d.ts +0 -12
  33. package/imperative/utils/microDebounce.d.ts +0 -0
  34. package/imperative/utils/pEachChunk.d.ts +0 -2
  35. package/imperative/utils/removeUndefined.d.ts +0 -1
  36. package/imperative/utils/requestCoverage.d.ts +0 -25
  37. package/imperative/utils/sphere-geo-utils.d.ts +0 -1
  38. /package/imperative/{utils/projections → projections}/index.d.ts +0 -0
@@ -122,11 +122,19 @@ interface VectorTileDataSourceDescription {
122
122
  meshRequestWithCredentials?: boolean;
123
123
  glyphRequestWithCredentials?: boolean;
124
124
  richModelRequestWithCredentials?: boolean;
125
+ indoorPlanRequestWithCredentials?: boolean;
126
+ styleRequestWithCredentials?: boolean;
127
+ fontListRequestWithCredentials?: boolean;
128
+ fontObjectRequestWithCredentials?: boolean;
125
129
  tileRequestHeaders?: Record<string, string>;
126
130
  iconRequestHeaders?: Record<string, string>;
127
131
  glyphRequestHeaders?: Record<string, string>;
128
132
  meshRequestHeaders?: Record<string, string>;
129
133
  richModelRequestHeaders?: Record<string, string>;
134
+ indoorPlanRequestHeaders?: Record<string, string>;
135
+ styleRequestHeaders?: Record<string, string>;
136
+ fontListRequestHeaders?: Record<string, string>;
137
+ fontObjectRequestHeaders?: Record<string, string>;
130
138
  priority: VectorDataSourcePriority;
131
139
  collisionPriority?: VectorObjectsCollisionPriority;
132
140
  requestTileSize?: VectorTileSize;
@@ -18,8 +18,8 @@ export declare function createDomContext(containerEntity: GenericComplexEntity<u
18
18
  /**
19
19
  * Hook for providing DOM context in entity
20
20
  * @param entity - Entity to provide the DomContext
21
- * @param element - Dom element that is passed to DomContext
22
- * @param container - Inner DOM element that is passed to the DOMContext
21
+ * @param element - DOM element to attach
22
+ * @param container - DOM element to provide to descendants in new DomContext
23
23
  * @returns Function that detaches the DOM element and DomContext from the entity
24
24
  */
25
25
  export declare function useDomContext(entity: GenericComplexEntity<unknown>, element: Element, container: Element | null): DomDetach;
@@ -6,29 +6,51 @@ import { Config } from "../config";
6
6
  import { MMapTheme } from "../ThemeContext";
7
7
  import { overrideKeyReactify } from "../wrappers";
8
8
  /**
9
- * Sets map center.
9
+ * Sets map center. In this case, the zoom of the map remains unchanged.
10
+ * ```javascript
11
+ * map.update({
12
+ * location: {center: [-0.118092, 51.509865]}
13
+ * });
14
+ * ```
10
15
  */
11
16
  export type MMapCenterLocation = {
12
17
  center: LngLat;
13
18
  };
14
19
  /**
15
- * Sets map zoom.
20
+ * Sets map zoom. In this case, the center of the map remains unchanged.
21
+ * ```javascript
22
+ * map.update({
23
+ * location: {zoom: 10}
24
+ * });
25
+ * ```
16
26
  */
17
27
  export type MMapZoomLocation = {
18
28
  zoom: number;
19
29
  };
20
30
  /**
21
- * Sets map bounds.
31
+ * Calculate the center and zoom by specifying the coordinates of the top left and bottom right corners of the map.
32
+ * In this case, the center of the map will be in the center of the rectangle described at the given coordinates.
33
+ * If the map have an aspect ratio different from this rectangle, the rectangle will be inscribed in height and the map will be centered in width.
34
+ * ```javascript
35
+ * map.update({
36
+ * location: {bounds: [[-0.118092, 51.509865], [-0.118092, 51.509865]]}
37
+ * });
38
+ * ```
22
39
  */
23
40
  export type MMapBoundsLocation = {
24
41
  bounds: LngLatBounds;
25
42
  };
26
43
  /**
27
44
  * Sets map center and zoom. Combination of MMapCenterLocation and MMapZoomLocation
45
+ * ```javascript
46
+ * map.update({
47
+ * location: {center: [-0.118092, 51.509865], zoom: 10}
48
+ * });
49
+ * ```
28
50
  */
29
51
  export type MMapCenterZoomLocation = MMapCenterLocation & MMapZoomLocation;
30
52
  /**
31
- * Sets map center and zoom or bounds. Combination of @mixes MMapZoomLocation and MMapBoundsLocation
53
+ * Union type for describing the position of the map through the center and zoom or through the bounds of the map
32
54
  */
33
55
  export type MMapLocation = MMapCenterZoomLocation & Partial<MMapBoundsLocation>;
34
56
  /**
@@ -41,7 +63,27 @@ export type MMapCamera = {
41
63
  azimuth?: number;
42
64
  };
43
65
  /**
44
- * Describes how to change current map location. Change can be instantenious or animated if duration property is set.
66
+ * Describes how to change current map location. Change can be instantaneous or animated if duration property is set.
67
+ * ```javascript
68
+ * map.update({
69
+ * location: {
70
+ * center: [-0.118092, 51.509865], // Center of the map
71
+ * zoom: 10, // Zoom level
72
+ * duration: 200, // Animation of moving map will take 200 milliseconds
73
+ * easing: 'ease-in-out' // Animation easing function
74
+ * }
75
+ * });
76
+ * ```
77
+ * or just change center of the map
78
+ * ```javascript
79
+ * map.update({
80
+ * location: {
81
+ * center: [-0.118092, 51.509865], // Center of the map
82
+ * duration: 200, // Animation of moving map will take 200 milliseconds
83
+ * easing: 'linear' // Animation easing function
84
+ * }
85
+ * })';
86
+ * ```
45
87
  */
46
88
  export type MMapLocationRequest = (MMapBoundsLocation | MMapCenterLocation | MMapZoomLocation | MMapCenterZoomLocation) & {
47
89
  /** Animation duration */
@@ -49,6 +91,17 @@ export type MMapLocationRequest = (MMapBoundsLocation | MMapCenterLocation | MMa
49
91
  /** Animation easing function */
50
92
  easing?: EasingFunctionDescription;
51
93
  };
94
+ /**
95
+ * Describes how to change current camera position. Change can be instantaneous or animated if duration property is set.
96
+ * ```javascript
97
+ * map.update({camera: {
98
+ * tilt: 45 * (Math.PI / 180), // 45 degrees
99
+ * azimuth: 30 * (Math.PI / 180) // 30 degrees
100
+ * duration: 200, // Animation of moving camera will take 200 milliseconds
101
+ * easing: 'ease-in-out'
102
+ * }});
103
+ * ```
104
+ */
52
105
  export type MMapCameraRequest = MMapCamera & {
53
106
  /** Animation duration */
54
107
  duration?: number;
@@ -56,7 +109,24 @@ export type MMapCameraRequest = MMapCamera & {
56
109
  easing?: EasingFunctionDescription;
57
110
  };
58
111
  /**
59
- * MMap props
112
+ * Map settings. Allow to set map mode, behaviors, margin, zoom rounding, zoom range, restrict map area, theme and other settings.
113
+ * ```javascript
114
+ * const map = new MMap(document.getElementById('map-root'), {
115
+ * className: 'custom-map',
116
+ * location: {center: [-0.118092, 51.509865], zoom: 10},
117
+ * camera: {tilt: 45 * (Math.PI / 180), azimuth: 30 * (Math.PI / 180)}
118
+ * mode: 'raster',
119
+ * behaviors: ['drag', 'scrollZoom', 'dblClick', 'mouseRotate', 'mouseTilt'],
120
+ * margin: [0, 100, 0, 0],
121
+ * theme: 'light'
122
+ * });
123
+ * ```
124
+ * But required only `location` prop.
125
+ * ```javascript
126
+ * const map = new MMap(document.getElementById('map-root'), {
127
+ * location: {center: [-0.118092, 51.509865], zoom: 10}
128
+ * });
129
+ * ```
60
130
  */
61
131
  export type MMapProps = {
62
132
  /** Map container css class name */
@@ -131,7 +201,7 @@ type DefaultProps = typeof defaultProps;
131
201
  * ```javascript
132
202
  * const map = new MMap(
133
203
  * document.getElementById('map-root'),
134
- * {location: {center: [37.622504, 55.753215], zoom: 10}}
204
+ * {location: {center: [-0.118092, 51.509865], zoom: 10}}
135
205
  * );
136
206
  * // add default Mappable scheme layer
137
207
  * map.addChild(new MMapDefaultSchemeLayer());
@@ -1,2 +1,2 @@
1
- import { WebMercator } from "../utils/projections/web-mercator";
1
+ import { WebMercator } from "../projections/web-mercator";
2
2
  export declare const projection: WebMercator;
@@ -1,3 +1,21 @@
1
1
  import { MMapGroupEntity } from "../MMapEnities";
2
+ /**
3
+ * MMapCollection is a collection of MMapEntity objects.
4
+ * Allow adding or removing [[MMapEntity]] objects.
5
+ * ```typescript
6
+ * const collection = new MMapCollection({});
7
+ * const markerElement = document.createElement('div');
8
+ * markerElement.className = 'marker';
9
+ *
10
+ * for (let i = 0; i < 10_000; i++) {
11
+ * collection.addChild(new MMapMarker({
12
+ * coordinates: [Math.random() * 180, Math.random() * 180]
13
+ * }, markerElement.cloneNode(true)));
14
+ * }
15
+ *
16
+ * map.addChild(collection); // Add collection to the map
17
+ * map.removeChild(collection); // Remove all markers from the map
18
+ * ```
19
+ */
2
20
  export declare class MMapCollection extends MMapGroupEntity<{}> {
3
21
  }
@@ -17,6 +17,20 @@ declare const defaultProps: {
17
17
  };
18
18
  type DefaultProps = typeof defaultProps;
19
19
  type ComputedMMapContainerProps<TContext> = MMapContainerProps<TContext> & MMapContainerPropsImpl<TContext>;
20
+ /**
21
+ * Allow adding or removing [[MMapEntity]] objects or usual DOM elements inside the MMap.
22
+ * ```tsx
23
+ * const container = <MMapContainer>
24
+ * <MMapMarker coordinates={[55.76, 37.64]}><div className="point"></div></MMapMarker>
25
+ * <div>Some text</div>
26
+ * </MMapContainer>;
27
+ *
28
+ * ReactDOM.render(<MMap>{container}</MMap, document.getElementById('root'));
29
+ * ```
30
+ * In this example, the `container` variable contains a `MMapContainer` object with two children: `MMapMarker` and `div`.
31
+ * - `MMapMarker` is a MMapEntity
32
+ * - `div` is a usual DOM element
33
+ */
20
34
  declare class MMapContainer extends MMapGroupEntity<ComputedMMapContainerProps<unknown>, DefaultProps> {
21
35
  static defaultProps: {
22
36
  tagName: string;
@@ -11,13 +11,38 @@ export type MMapContextProviderProps<T> = {
11
11
  };
12
12
  /**
13
13
  * Context provider for MMap, allowing to inject a context and its value.
14
- * @example
14
+ *
15
15
  * ```javascript
16
16
  * const mapContextProvider = new MMapContextProvider({context: SomeMapContext, value: {your: 'value'}});
17
- * mapContextProvider.addChild(new MMapDefaultSchemeLayer({}));
18
17
  * map.addChild(mapContextProvider);
19
18
  * ```
20
- * `MMapDefaultSchemeLayer` will receive the context `SomeMapContext` with the value `{ your: 'value' }`
19
+ * And define context consumer:
20
+ * ```ts
21
+ * class SomeContextConsumer extends mappable.MMapEntity<{}> {
22
+ * constructor() {
23
+ * super({});
24
+ * }
25
+ *
26
+ * _onAttach() {
27
+ * const value = this._consumeContext(SomeMapContext);
28
+ * console.log(value); // {your: 'value'}
29
+ * }
30
+ * }
31
+ * ```
32
+ * When adding nested containers, the context will be available in them:
33
+ * ```ts
34
+ * mapContextProvider.addChild(new SomeContextConsumer());
35
+ * ```
36
+ * But the most important thing is that the context can be passed at any nesting level:
37
+ * ```tsx
38
+ * <MMapContextProvider context={SomeMapContext} value={{your: 'value'}}>
39
+ * <MMapContainer>
40
+ * <MMapContainer>
41
+ * <SomeContextConsumer />
42
+ * <MMapContainer>
43
+ * </MMapContainer>
44
+ * </MMapContextProvider>
45
+ * ```
21
46
  */
22
47
  export declare class MMapContextProvider<T> extends MMapGroupEntity<MMapContextProviderProps<T>> {
23
48
  protected _onAttach(): void;
@@ -1,7 +1,18 @@
1
1
  import { MMapComplexEntity, MMapGroupEntity } from "../MMapEnities";
2
2
  import { overrideKeyReactify } from "../wrappers";
3
3
  /**
4
- * MMapControlButton props
4
+ * Properties for [[MMapControlCommonButton]]
5
+ * ```typescript
6
+ * const button = new MMapControlCommonButton({
7
+ * text: 'Click me!',
8
+ * disabled: false,
9
+ * color: 'black',
10
+ * background: 'white',
11
+ * onClick: () => {
12
+ * console.log('Button clicked');
13
+ * }
14
+ * });
15
+ * ```
5
16
  */
6
17
  export type MMapControlCommonButtonProps = {
7
18
  /** On click handler */
@@ -20,7 +31,19 @@ export type MMapControlCommonButtonProps = {
20
31
  export type MMapControlButtonProps = MMapControlCommonButtonProps;
21
32
  /** @module MMapControlButton */
22
33
  /**
23
- * Default control button.
34
+ * Default control button. Can be used as a base for custom controls.
35
+ * ```javascript
36
+ * const map = new mappable.MMap(document.getElementById('map-root'), {...});
37
+ * const controls = new mappable.MMapControls({position: 'bottom right'});
38
+ * const button = new mappable.MMapControlCommonButton({
39
+ * text: 'Click me!',
40
+ * onClick: () => {
41
+ * console.log('Button clicked');
42
+ * }
43
+ * });
44
+ * controls.addChild(button);
45
+ * ```
46
+ * More about controls: [Mappable Maps API controls](https://mappable.world/docs/js-api/dg/concepts/controls/index.html)
24
47
  */
25
48
  export declare class MMapControlCommonButton extends MMapGroupEntity<MMapControlCommonButtonProps> {
26
49
  private _element?;
@@ -1,4 +1,13 @@
1
1
  import { MMapGroupEntity } from "../MMapEnities";
2
+ /**
3
+ * Copyrights position on the map container. By default, 'bottom right'.
4
+ * For example, 'top left' or 'bottom right'
5
+ * ```javascript
6
+ * const map = new mappable.MMap(document.getElementById('map-root'), {
7
+ * copyrightsPosition: 'top left'
8
+ * });
9
+ * ```
10
+ */
2
11
  type MMapCopyrightsPosition = "top left" | "top right" | "bottom left" | "bottom right";
3
12
  type MMapCopyrightsProps = {
4
13
  /** Position of copyright on the map */
@@ -20,35 +29,25 @@ declare class MMapCopyrights extends MMapGroupEntity<MMapCopyrightsProps, Defaul
20
29
  position: MMapCopyrightsPosition;
21
30
  showScale: false;
22
31
  }>;
23
- private _boxElement;
32
+ private _containerElement;
24
33
  private _copyrightsTextElement;
25
- private _linkElement;
34
+ private _agreementLinkElement;
26
35
  private _logoElement;
27
36
  private _copyrightsContainer;
28
37
  private _scaleElement;
29
38
  private _scaleControl;
30
- private _mapWidth;
31
39
  private _copyrights;
32
- private _fixedCopyrights;
33
- private _userAgreementText;
34
- private _userAgreementState;
35
- private _unwatchMapContext?;
36
- private _unwatchThemeContext?;
37
40
  private _detachDom?;
38
41
  constructor(props?: MMapCopyrightsProps);
39
42
  protected _onAttach(): void;
40
43
  protected _onUpdate(props: Partial<MMapCopyrightsProps>): void;
41
44
  protected _onDetach(): void;
42
45
  private _createDom;
43
- private _syncDom;
44
- private _syncMapWidth;
46
+ private _render;
45
47
  private _syncTheme;
46
- private _setUserAgreementText;
47
- private _setUserAgreementState;
48
- private _setCopyrights;
49
- private _setFixedCopyrights;
50
- private _copyrightsChangeHandler;
51
- private _adjustText;
48
+ private _applyCopyrights;
49
+ private _computeMaxWidth;
50
+ private _rearrange;
52
51
  private _toggleScaleControl;
53
52
  }
54
53
  export { MMapCopyrights, MMapCopyrightsPosition, MMapCopyrightsProps };
@@ -1,6 +1,16 @@
1
1
  import type { VectorCustomization } from "../../common/types";
2
2
  import { MMapLayerProps } from "../MMapLayer";
3
3
  import { MMapComplexEntity } from "../MMapEnities";
4
+ /**
5
+ * Types of underlay layers available in the default scheme.
6
+ * Each layer is displayed on the map according to its zIndex.
7
+ * By default, layers are displayed in the following order:
8
+ * 1. ground
9
+ * 2. buildings
10
+ * 3. icons
11
+ * 4. labels
12
+ * @see https://mappable.world/docs/js-api/dg/concepts/general.html#source-prepared
13
+ */
4
14
  type MMapDefaultSchemeLayerType = "ground" | "buildings" | "icons" | "labels";
5
15
  /**
6
16
  * MMapDefaultSchemeLayer props
@@ -30,7 +40,7 @@ type MMapDefaultSchemeLayerProps = {
30
40
  * const defaultSchemeLayer = new MMapDefaultSchemeLayer({clampMapZoom: false});
31
41
  * map.addChild(defaultSchemeLayer);
32
42
  * ```
33
- * See example https://mappable.world/docs/jsapi/examples/cases/over-zoom
43
+ * See example https://mappable.world/docs/js-api/examples/cases/over-zoom.html
34
44
  * @default true
35
45
  */
36
46
  clampMapZoom?: boolean;
@@ -65,8 +75,6 @@ declare const MAP_TYPES: {
65
75
  admin: string;
66
76
  driving: string;
67
77
  transit: string;
68
- "future-map": string;
69
- "legacy-map": string;
70
78
  };
71
79
  /**
72
80
  * Map default layer to show mappable-world scheme on map.
@@ -91,4 +91,51 @@ declare abstract class MMapGroupEntity<Props, DefaultProps extends {} = {}> exte
91
91
  addChild(child: MMapEntity<unknown>, index?: number): this;
92
92
  removeChild(child: MMapEntity<unknown>): this;
93
93
  }
94
- export { MMapEntity, MMapComplexEntity, MMapGroupEntity, Context as MMapContext };
94
+ /**
95
+ * Context for MMap. It allows you to provide a value to the context and use it in the children of the context provider.
96
+ * ```ts
97
+ * const MMapSomeContext = new mappable.MMapContext('MMapSomeContext');
98
+ * class SomeValueProvider extends mappable.MMapGroupEntity<{}> {
99
+ * constructor() {
100
+ * super({});
101
+ * this._provideContext(MMapSomeContext, {your: 'value'}); // Special method to provide context value
102
+ * }
103
+ * }
104
+ * ```
105
+ * And some child entity can use this context:
106
+ * ```ts
107
+ * class SomeContextConsumer extends mappable.MMapEntity<{}> {
108
+ * constructor() {
109
+ * super({});
110
+ * }
111
+ *
112
+ * _onAttach() {
113
+ * const value = this._consumeContext(MMapSomeContext); // Special method to get context value
114
+ * console.log(value); // {your: 'value'}
115
+ * }
116
+ * }
117
+ * ```
118
+ * In any level of nesting:
119
+ * ```tsx
120
+ * <SomeValueProvider>
121
+ * <MMapContainer>
122
+ * <MMapContainer>
123
+ * <SomeContextConsumer />
124
+ * </MMapContainer>
125
+ * </MMapContainer>
126
+ * </SomeEntity>
127
+ * ```
128
+ * You can set the context value using [[MMapContextProvider]]:
129
+ * ```tsx
130
+ * <MMapContextProvider context={MMapSomeContext} value={{your: 'value'}}>
131
+ * <MMapContainer>
132
+ * <MMapContainer>
133
+ * <SomeContextConsumer />
134
+ * </MMapContainer>
135
+ * </MMapContainer>
136
+ * </SomeEntity>
137
+ * ```
138
+ */
139
+ declare class MMapContext<T> extends Context<T> {
140
+ }
141
+ export { MMapEntity, MMapComplexEntity, MMapGroupEntity, MMapContext };
@@ -23,9 +23,10 @@ type DefaultProps = typeof defaultProps & {
23
23
  id: string;
24
24
  };
25
25
  /**
26
- * The feature component on the map.
26
+ * Component for creating a geo object on the map.
27
+ * Supports drag-and-drop functionality, drawing styles, and event handling.
28
+ * Supported geometries: `Point`, `LineString`, `MultiLineString`, `Polygon` and `MultiPolygon`.
27
29
  *
28
- * @example
29
30
  * ```javascript
30
31
  * const feature = new MMapFeature({
31
32
  * geometry: {
@@ -43,6 +44,19 @@ type DefaultProps = typeof defaultProps & {
43
44
  * .addChild(new MMapDefaultFeaturesLayer())
44
45
  * .addChild(feature);
45
46
  * ```
47
+ * You can add Point geometry with HTMLElement:
48
+ * ```javascript
49
+ * const feature = new MMapFeature({
50
+ * geometry: {
51
+ * type: 'Point',
52
+ * coordinates: [37.40108963847453, 55.70173382087952]
53
+ * },
54
+ * style: {
55
+ * element: document.createElement('div')
56
+ * }
57
+ * });
58
+ * ```
59
+ * But better to use [[MMapMarker]] for this.
46
60
  */
47
61
  declare class MMapFeature extends MMapEntity<MMapFeatureProps, DefaultProps> {
48
62
  static defaultProps: Readonly<{
@@ -50,4 +50,19 @@ export interface FeatureClickEvents {
50
50
  onFastClick?: (event: MouseEvent, mapEvent: MapEvent) => void;
51
51
  }
52
52
  export type Geometry = PolygonGeometry | MultiPolygonGeometry | LineStringGeometry | MultiLineStringGeometry | PointGeometry;
53
+ /**
54
+ * Feature drag event handler.
55
+ * ```typescript
56
+ * function onDragEvent(type, coordinates) => {
57
+ * console.log('Event:', type, coordinates);
58
+ * };
59
+ * const feature = new MMapFeature({
60
+ * geometry: {...},
61
+ * draggable: true,
62
+ * onDragStart: onDragEvent.bind(null, 'dragStart'),
63
+ * onDragMove: onDragEvent.bind(null, 'dragMove'),
64
+ * onDragEnd: onDragEvent.bind(null, 'dragEnd'),
65
+ * });
66
+ * ```
67
+ */
53
68
  export type MMapFeatureEventHandler = (coordinates: Geometry['coordinates']) => void | false;
@@ -1,7 +1,21 @@
1
1
  import type { GenericGeometry, LngLat } from "../../common/types";
2
2
  /**
3
+ * Some active area on the map that can be clicked.
3
4
  * This is not a real MMapEntity, it cannot be added to the map.
4
5
  * But you can check it by `instance of` in MMapListener handlers
6
+ * For example, in [custom layers](https://mappable.world/docs/js-api/dg/concepts/custom-layers.html) you can pass an object of this type in the `findObjectInPosition` method
7
+ * Or just listen to the `onEventName` event and check the object:
8
+ * ```javascript
9
+ * const map = new mappable.MMap(document.getElementById('map-root'), {...});
10
+ * map.addChild(new mappable.MMapListener({
11
+ * layer: 'any',
12
+ * onClick: (object) => {
13
+ * if (object instanceof mappable.MMapHotspot) {
14
+ * console.log('Hotspot clicked', object);
15
+ * }
16
+ * }
17
+ * }))
18
+ * ```
5
19
  */
6
20
  declare class MMapHotspot {
7
21
  private static _uid;
@@ -1,9 +1,18 @@
1
1
  import { MMapContainer, MMapContainerProps, MMapContainerPropsImpl } from "../MMapContainer";
2
- /** @deprecated Use MMapContainerPropsImpl instead */
2
+ /**
3
+ * @deprecated Use {@link MMapContainerPropsImpl} instead
4
+ * @private
5
+ */
3
6
  type MMapReactContainerPropsImpl<TContext> = MMapContainerPropsImpl<TContext>;
4
- /** @deprecated Use MMapContainerProps instead */
7
+ /**
8
+ * @deprecated Use {@link MMapContainerProps} instead
9
+ * @private
10
+ */
5
11
  type MMapReactContainerProps<TContext> = MMapContainerProps<TContext>;
6
- /** @deprecated Use MMapContainer instead */
12
+ /**
13
+ * @deprecated Use {@link MMapContainer} instead
14
+ * @private
15
+ */
7
16
  declare class MMapReactContainer extends MMapContainer {
8
17
  }
9
18
  export { MMapReactContainer, MMapReactContainerPropsImpl, MMapReactContainerProps };
@@ -1,5 +1,11 @@
1
1
  import { MMapComplexEntity } from "../MMapEnities";
2
+ /**
3
+ * Types of measurement units that scale control can display.
4
+ */
2
5
  export type UnitType = "imperial" | "metric" | "nautical";
6
+ /**
7
+ * Properties for [[MMapScaleControl]]
8
+ */
3
9
  type MMapScaleControlProps = {
4
10
  /** Maximum width of scale line in pixels */
5
11
  maxWidth?: number;
@@ -11,6 +17,22 @@ declare const defaultProps: Readonly<{
11
17
  unit: "metric";
12
18
  }>;
13
19
  type DefaultProps = typeof defaultProps;
20
+ /**
21
+ * A control that shows the map scale in different units of measurement.
22
+ * @example Add scale control to the lower left part of the map:
23
+ * ```js
24
+ * const scaleControl = new MMapScaleControl({});
25
+ * const controls = new MMapControls({position: 'bottom left'}, [scaleControl]);
26
+ * map.addChild(controls)
27
+ * ```
28
+ * Alternatively, you can show the integrated scale control on the map by `showScaleInCopyrights` props:
29
+ * ```js
30
+ * const map = new MMap(document.getElementById('map-root'), {
31
+ * showScaleInCopyrights: true,
32
+ * location: {center: [37.622504, 55.753215], zoom: 10}
33
+ * });
34
+ * ```
35
+ */
14
36
  declare class MMapScaleControl extends MMapComplexEntity<MMapScaleControlProps, DefaultProps> {
15
37
  static defaultProps: Readonly<{
16
38
  maxWidth: 74;
@@ -1,9 +1,9 @@
1
- import type { RasterTileDataSourceDescription, VectorTileDataSourceDescription, ZoomRange } from "../../common/types";
1
+ import type { RasterTileDataSourceDescription, ZoomRange } from "../../common/types";
2
2
  import { MMapEntity } from "../MMapEnities";
3
3
  /**
4
4
  * MMapTileDataSource props
5
5
  */
6
- type MMapTileDataSourceProps = {
6
+ interface MMapTileDataSourceProps {
7
7
  /** Data source id */
8
8
  id: string;
9
9
  /** Min and max zoom for tiles */
@@ -18,7 +18,7 @@ type MMapTileDataSourceProps = {
18
18
  raster?: RasterTileDataSourceDescription;
19
19
  /** Data source copyrights */
20
20
  copyrights?: string[];
21
- };
21
+ }
22
22
  /**
23
23
  * Create map tile data source.
24
24
  *
@@ -1,6 +1,12 @@
1
1
  import { Context } from "./Entities";
2
2
  /**
3
- * Sets map theme
3
+ * Map theme. Affects the colors of the map controls and background.
4
+ * ```typescript
5
+ * const map = new mappable.MMap({
6
+ * location: {center: [55.751574, 37.573856], zoom: 9},
7
+ * theme: 'dark'
8
+ * });
9
+ * ```
4
10
  */
5
11
  export type MMapTheme = "light" | "dark";
6
12
  export type MMapThemeContext = {
@@ -3,4 +3,7 @@ export type MMapType = string;
3
3
  export type MMapTypeContext = {
4
4
  type?: MMapType;
5
5
  };
6
+ /**
7
+ * Selects one of predefined map style modes optimized for particular use case.
8
+ */
6
9
  export declare const TypeContext: Context<MMapTypeContext>;
@@ -1,11 +1,36 @@
1
+ /**
2
+ * All possible apikeys for http-services.
3
+ */
1
4
  interface Apikeys {
2
5
  suggest?: string;
3
6
  router?: string;
4
7
  search?: string;
5
8
  }
9
+ /**
10
+ * Configuration object for whole API.
11
+ * For example, it can be used to set experiments or apikeys.
12
+ * ```js
13
+ * mappable.getDefaultConfig().setApikeys({search: "YOUR_SEARCH_API_KEY"})`.
14
+ * ```
15
+ */
6
16
  export declare class Config {
7
17
  readonly description: string;
18
+ /**
19
+ * Set experiments for map.
20
+ */
8
21
  setExperiments(experiments: Record<string, boolean>): void;
22
+ /**
23
+ * Set apikeys for http-services.
24
+ * ```js
25
+ * mappable.getDefaultConfig().setApikeys({search: "YOUR_SEARCH_API_KEY"})`.
26
+ * ```
27
+ */
9
28
  setApikeys(apikeys: Apikeys): void;
10
29
  }
30
+ /**
31
+ * Returns default config object.
32
+ * ```js
33
+ * mappable.getDefaultConfig().setApikeys({suggest: "YOUR_SUGGEST_API_KEY"})`.
34
+ * ```
35
+ */
11
36
  export declare function getDefaultConfig(): Config;
@@ -1,4 +1,4 @@
1
- import * as projections_ from "./utils/projections";
1
+ import * as projections_ from "./projections";
2
2
  export { MMap, MMapProps, MMapCenterLocation, MMapZoomLocation, MMapBoundsLocation, MMapCenterZoomLocation, MMapLocationRequest, MMapCameraRequest } from "./MMap";
3
3
  export { MMapThemeContext, ThemeContext, MMapTheme } from "./ThemeContext";
4
4
  export { MMapTypeContext, TypeContext, MMapType } from "./TypeContext";
@@ -1,11 +1,9 @@
1
- import type { Projection, LngLat, WorldCoordinates } from "../../../common/types";
1
+ import type { Projection, LngLat, WorldCoordinates } from "../../common/types";
2
2
  /**
3
- * @class Mercator projection onto a sphere.
4
- * Used by many mapping services, in particular OpenStreetMap.
5
- * @name projection.webMercator
6
- * @augments Projection
7
- * @static
8
- * @example
3
+ * @private
4
+ * Mercator projection onto a sphere.
5
+ * Used by many mapping services, in particular OpenStreetMap
6
+ *
9
7
  * ```js
10
8
  * // Create a map in the web Mercator projection
11
9
  * const map = new mappable.MMap(document.getElementById('MMapsID'), {
package/package.json CHANGED
@@ -1,23 +1,36 @@
1
1
  {
2
- "name": "@mappable-world/mappable-types",
3
- "version": "0.0.21",
4
- "description": "Types for mappable maps library",
5
- "main": "",
6
- "types": "index.d.ts",
7
- "keywords": ["mappable-world", "api", "map", "mappable", "types", "js api"],
8
- "publishConfig": {
9
- "registry": "https://registry.npmjs.org"
2
+ "name": "@mappable-world/mappable-types",
3
+ "version": "0.0.15085412",
4
+ "description": "Types for mappable maps library",
5
+ "main": "",
6
+ "types": "index.d.ts",
7
+ "keywords": [
8
+ "mappable-world",
9
+ "api",
10
+ "map",
11
+ "mappable",
12
+ "types",
13
+ "js api"
14
+ ],
15
+ "publishConfig": {
16
+ "registry": "https://registry.npmjs.org"
17
+ },
18
+ "homepage": "https://mappable.world",
19
+ "license": "Apache-2.0",
20
+ "peerDependencies": {
21
+ "@types/react": "16-18",
22
+ "@types/react-dom": "16-18",
23
+ "@vue/runtime-core": "3"
24
+ },
25
+ "peerDependenciesMeta": {
26
+ "@types/react": {
27
+ "optional": true
10
28
  },
11
- "homepage": "https://mappable.world",
12
- "license": "Apache-2.0",
13
- "peerDependencies": {
14
- "@types/react": "16-18",
15
- "@types/react-dom": "16-18",
16
- "@vue/runtime-core": "3"
29
+ "@types/react-dom": {
30
+ "optional": true
17
31
  },
18
- "peerDependenciesMeta": {
19
- "@types/react": {"optional": true},
20
- "@types/react-dom": {"optional": true},
21
- "@vue/runtime-core": {"optional": true}
32
+ "@vue/runtime-core": {
33
+ "optional": true
22
34
  }
35
+ }
23
36
  }
@@ -6,7 +6,7 @@ import { optionsKeyVuefy, overrideKeyReactify, overrideKeyVuefy } from "../../..
6
6
  type MMapHintProps = {
7
7
  hint: (object: MMapFeature | MMapMarker | MMapHotspot | undefined) => unknown;
8
8
  };
9
- declare const MMapHintContext: import("../../../imperative/Entities").Context<unknown>;
9
+ declare const MMapHintContext: import("../../../imperative/MMapEnities").MMapContext<unknown>;
10
10
  /**
11
11
  * Display hint on map elements.
12
12
  *
@@ -1,55 +0,0 @@
1
- import type { ZoomRange } from "../../common/types";
2
- import { MMapComplexEntity } from "../MMapEnities";
3
- import { Context } from "../Entities";
4
- interface MMapCoverageProps {
5
- onError?: (e: Error) => void;
6
- }
7
- export interface CoverageContext {
8
- subscribe(args: CoverageSubscriptionArgs): CoverageSubscription;
9
- }
10
- export declare const CoverageContext: Context<CoverageContext>;
11
- /**
12
- * The component of loading data on copyrights on the map and the zoom range for
13
- * the area where the center of the map is located
14
- */
15
- declare class MMapCoverage extends MMapComplexEntity<MMapCoverageProps, {}> {
16
- private _abortController?;
17
- private _coverageArgs?;
18
- private _subscriptions;
19
- private readonly _queueRequest;
20
- private readonly _queueRequestStamps;
21
- private _stampsRequestsInterval?;
22
- private _currentIntervalMs;
23
- private _stampsAbortController?;
24
- constructor(props?: MMapCoverageProps);
25
- subscribe(args: CoverageSubscriptionArgs): CoverageSubscription;
26
- protected _onAttach(): void;
27
- protected _onDetach(): void;
28
- protected _scheduleStampsRequests(): void;
29
- private _onMapContextChange;
30
- private _request;
31
- _requestStamps(): void;
32
- }
33
- export interface CoverageSubscriptionArgs {
34
- layer: string;
35
- maptype: string | undefined;
36
- versioned?: {
37
- interval: number;
38
- };
39
- onUpdate: () => void;
40
- }
41
- export declare class CoverageSubscription {
42
- private readonly _onDestroy;
43
- readonly layer: string;
44
- readonly maptype: string | undefined;
45
- readonly onUpdate: () => void;
46
- readonly versioned?: {
47
- interval: number;
48
- };
49
- copyrights?: string[];
50
- zoomRange?: ZoomRange;
51
- version?: string;
52
- constructor(args: CoverageSubscriptionArgs, _onDestroy: () => void);
53
- destroy(): void;
54
- }
55
- export { MMapCoverage, MMapCoverageProps };
@@ -1 +0,0 @@
1
- import type { LayerImplementationClasses } from "../../common/types/layer-implementation";
@@ -1,2 +0,0 @@
1
- declare function deepFreeze<ObjectType>(obj: ObjectType): ObjectType;
2
- export { deepFreeze };
@@ -1,29 +0,0 @@
1
- interface MappableError extends Error {
2
- additionalInfo?: Additional;
3
- logged?: boolean;
4
- }
5
- type Additional = Record<string, unknown>;
6
- interface LogErrorOptions {
7
- message?: string;
8
- service?: string;
9
- source?: string;
10
- sourceMethod?: string;
11
- type?: string;
12
- block?: string;
13
- method?: string;
14
- page?: string;
15
- additional?: Additional;
16
- level?: "info" | "debug" | "warn" | "error" | "critical" | "trace";
17
- }
18
- interface LogErrorInitSettings {
19
- project?: string;
20
- unhandledRejection?: boolean;
21
- uncaughtException?: boolean;
22
- }
23
- type ErrorLoggerInitFunction = (settings: LogErrorInitSettings) => ErrorLoggerFunction;
24
- type ErrorLoggerFunction = (options: LogErrorOptions, error?: MappableError) => void;
25
- export type MappableReactError = Omit<MappableError, "logged">;
26
- export { ErrorLoggerInitFunction };
27
- export declare function errorLoggerFactory(initLogger: ErrorLoggerInitFunction): void;
28
- export declare function logError(error: MappableReactError, options?: Record<string, unknown>): void;
29
- export declare function throwError(error: MappableReactError): never;
@@ -1,2 +0,0 @@
1
- declare function idIncrementedFactory(min?: number, max?: number): () => number;
2
- export { idIncrementedFactory };
@@ -1,3 +0,0 @@
1
- export * from "./errorLogger";
2
- export * from "./metrics";
3
- export * from "./requestCoverage";
@@ -1,9 +0,0 @@
1
- type BooleanFlag = 0 | 1;
2
- type JsonpRequest = {
3
- url: string;
4
- callbackName: string;
5
- };
6
- declare function boolToFlag(value: undefined | boolean): undefined | BooleanFlag;
7
- declare function composeUrl(baseUrl: string, params: Record<string, string | number | undefined>): string;
8
- declare function jsonp<JsonpResponse>({ url, callbackName }: JsonpRequest, signal?: AbortSignal): Promise<JsonpResponse>;
9
- export { jsonp, composeUrl, boolToFlag };
@@ -1,12 +0,0 @@
1
- type Metrics = {};
2
- type TransportOptions = {
3
- share?: number;
4
- };
5
- type MetricsTransport<T> = (metrics: T, options?: TransportOptions) => void;
6
- type CreateTransportOptions = {
7
- prefix?: string;
8
- /** Events with share (if defined) less than this value will not be sent, should be in [0, 1] range */
9
- sendBoundary?: number;
10
- };
11
- export declare const SEND_BOUNDARY: number;
12
- export {};
File without changes
@@ -1,2 +0,0 @@
1
- declare function pEachChunk<T>(data: T[], callback: (elem: T, index: number) => void, chunkSize?: number): Promise<void>;
2
- export { pEachChunk };
@@ -1 +0,0 @@
1
- export declare function removeUndefined<T extends {}>(obj: T, recursive?: boolean): T;
@@ -1,25 +0,0 @@
1
- import type { ReadonlyLngLat, ZoomRange } from "../../common/types";
2
- export type LayerInfo = {
3
- id: string;
4
- zoomRange?: ZoomRange;
5
- copyrights?: string[];
6
- LayerMetaData?: unknown[];
7
- version?: string;
8
- };
9
- export type Coverage = Map<string, LayerInfo>;
10
- export interface CoverageArgs {
11
- host: string;
12
- layers: string[];
13
- coordinates: ReadonlyLngLat;
14
- zoom: number;
15
- lang: string;
16
- maptype?: string | undefined;
17
- }
18
- declare function requestCoverage(args: CoverageArgs, signal?: AbortSignal): Promise<Coverage>;
19
- interface RequestStampsArgs {
20
- host: string;
21
- layers: string[];
22
- lang: string;
23
- }
24
- declare function requestStamps(args: RequestStampsArgs, signal?: AbortSignal): Promise<Coverage>;
25
- export { requestCoverage, requestStamps };
@@ -1 +0,0 @@
1
- import type { LngLat } from "../../common/types";