@mappable-world/mappable-types 0.0.13 → 0.0.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.
@@ -1,6 +1,11 @@
1
1
  import type { LngLat } from "./lng-lat";
2
2
  import type { WorldCoordinates } from "./coordinates";
3
3
  interface GenericProjection<TSource> {
4
+ /** Projection identity type. It may be:
5
+ * - EPSG-code (e.g. [EPSG:3857](https://epsg.io/3857))
6
+ * - any other string to identify (e.g. 'cartesian')
7
+ **/
8
+ readonly type?: string;
4
9
  toWorldCoordinates(point: TSource): WorldCoordinates;
5
10
  fromWorldCoordinates(coordinates: WorldCoordinates): TSource;
6
11
  }
@@ -1,2 +1,2 @@
1
- import { sphericalMercator } from "../utils/projections/spherical-mercator";
2
- export { sphericalMercator as projection };
1
+ import { WebMercator } from "../utils/projections/web-mercator";
2
+ export declare const projection: WebMercator;
@@ -79,8 +79,6 @@ declare class MMapDefaultSchemeLayer extends MMapComplexEntity<MMapDefaultScheme
79
79
  protected _onAttach(): void;
80
80
  protected _onDetach(): void;
81
81
  protected _onUpdate(propsDiff: Partial<MMapDefaultSchemeLayerProps>): void;
82
- private _createTileUrl;
83
- private _getProjectionQuery;
84
82
  private _getDataSourceDescription;
85
83
  private _updateTheme;
86
84
  }
@@ -1,3 +1,4 @@
1
+ import * as projections_ from "./utils/projections";
1
2
  export { MMap, MMapProps, MMapCenterLocation, MMapZoomLocation, MMapBoundsLocation, MMapCenterZoomLocation, MMapLocationRequest, MMapCameraRequest } from "./MMap";
2
3
  export { MMapThemeContext, ThemeContext, MMapTheme } from "./ThemeContext";
3
4
  export { MMapCopyrightsPosition } from "./MMapCopyrights";
@@ -24,7 +25,11 @@ export { geolocation } from "./geolocation";
24
25
  export { useDomContext, DomDetach } from "./DomContext";
25
26
  export { Config, getDefaultConfig } from "./config";
26
27
  export { fetchConfig, FetchConfigOptions } from "./fetchConfig";
27
- export * as projections from "./utils/projections";
28
+ /** @deprecated Use mappable packages instead */
29
+ export declare const projections: {
30
+ /** @deprecated Use [Web Mercator package](https://www.npmjs.com/package/@mappable-world/mappable-web-mercator-projection) instead. */
31
+ sphericalMercator: projections_.WebMercator;
32
+ };
28
33
  /** Toggle this to enable/disable strict mode. */
29
34
  export declare let strictMode: boolean;
30
35
  export type { LngLat, ReadonlyLngLat, LngLatBounds, BehaviorType, MapMode, Margin, ZoomRange, ZoomStrategy, ZoomRounding, VectorCustomizationTypes, VectorCustomizationElements, VectorCustomizationItem, VectorCustomization, RasterTileDataSourceDescription, VectorTileDataSourceDescription, RasterLayerOptions, EasingFunctionDescription, EasingPresetName, EasingBezierPreset, EasingFunction, DrawingStyle, DrawingStyleIcon, VectorTileSize, VectorObjectsCollisionPriority, VectorDataSourcePriority } from "../common/types";
@@ -0,0 +1 @@
1
+ import type { LayerImplementationClasses } from "../../common/types/layer-implementation";
@@ -1 +1 @@
1
- export * from "./spherical-mercator";
1
+ export * from "./web-mercator";
@@ -2,18 +2,18 @@ import type { Projection, LngLat, WorldCoordinates } from "../../../common/types
2
2
  /**
3
3
  * @class Mercator projection onto a sphere.
4
4
  * Used by many mapping services, in particular OpenStreetMap.
5
- * @name projection.sphericalMercator
5
+ * @name projection.webMercator
6
6
  * @augments Projection
7
7
  * @static
8
8
  * @example
9
9
  * ```js
10
- * // Create a map in the spherical Mercator projection
10
+ * // Create a map in the web Mercator projection
11
11
  * const map = new mappable.MMap(document.getElementById('MMapsID'), {
12
12
  * location: {
13
13
  * center: [37, 55],
14
14
  * zoom: 6
15
15
  * },
16
- * projection: new mappable.SphericalMercator()
16
+ * projection: new WebMercator()
17
17
  * });
18
18
  * const dataSourceProps = {
19
19
  * raster: {
@@ -34,8 +34,9 @@ import type { Projection, LngLat, WorldCoordinates } from "../../../common/types
34
34
  * });
35
35
  * ```
36
36
  */
37
- declare class SphericalMercator implements Projection {
37
+ export declare class WebMercator implements Projection {
38
38
  private _maxLatitudeRad;
39
+ type: string;
39
40
  toWorldCoordinates(coords: LngLat): WorldCoordinates;
40
41
  fromWorldCoordinates(world: WorldCoordinates): LngLat;
41
42
  private _worldXToLongitude;
@@ -43,5 +44,5 @@ declare class SphericalMercator implements Projection {
43
44
  private _latitudeToWorldY;
44
45
  private _worldYToLatitude;
45
46
  }
46
- declare const sphericalMercator: SphericalMercator;
47
- export { sphericalMercator };
47
+ /** @deprecated Use WebMercator instead */
48
+ export declare const SphericalMercator: typeof WebMercator;
@@ -0,0 +1,14 @@
1
+ import type { UnitType } from ".";
2
+ /**
3
+ * Converts the distance in one set of units to another set of units
4
+ * @param distance - non-rounded distance in meters
5
+ * @param unit - unit of measurement to be converted to
6
+ * @returns converted distance value
7
+ */
8
+ export declare function convertDistanceToUnit(distance: number, unit: UnitType): number;
9
+ /**
10
+ * Rounds off the integer distance to the nearest round number
11
+ * @param rawDistance - unrounded distance
12
+ * @returns Rounded distance
13
+ */
14
+ export declare function floorToNearestTenths(rawDistance: number): number;
@@ -0,0 +1,34 @@
1
+ import { MMapComplexEntity } from "../../../imperative";
2
+ export type UnitType = 'imperial' | 'metric' | 'nautical';
3
+ type MMapScaleControlProps = {
4
+ /** Maximum width of scale line in pixels */
5
+ maxWidth?: number;
6
+ /** Units of measurement for the scale line */
7
+ unit?: UnitType;
8
+ };
9
+ declare const defaultProps: Readonly<{
10
+ maxWidth: 85;
11
+ unit: "metric";
12
+ }>;
13
+ type DefaultProps = typeof defaultProps;
14
+ declare class MMapScaleControl extends MMapComplexEntity<MMapScaleControlProps, DefaultProps> {
15
+ static defaultProps: Readonly<{
16
+ maxWidth: 85;
17
+ unit: "metric";
18
+ }>;
19
+ private _unwatchThemeContext?;
20
+ private _detachDom?;
21
+ private _element?;
22
+ private _labelElement?;
23
+ private _listener?;
24
+ constructor(props: MMapScaleControlProps);
25
+ protected _onAttach(): void;
26
+ protected _onDetach(): void;
27
+ private _createDom;
28
+ private _updateDom;
29
+ private _updateTheme;
30
+ private _onMapUpdate;
31
+ private _updateDistance;
32
+ private _formatDistance;
33
+ }
34
+ export { MMapScaleControl, MMapScaleControlProps };
package/package.json CHANGED
@@ -1,25 +1,23 @@
1
1
  {
2
2
  "name": "@mappable-world/mappable-types",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "description": "Types for mappable maps library",
5
5
  "main": "",
6
6
  "types": "index.d.ts",
7
- "keywords": [
8
- "mappable-world",
9
- "api",
10
- "map",
11
- "mappable",
12
- "types",
13
- "js api"
14
- ],
7
+ "keywords": ["mappable-world", "api", "map", "mappable", "types", "js api"],
15
8
  "publishConfig": {
16
9
  "registry": "https://registry.npmjs.org"
17
10
  },
18
11
  "homepage": "https://mappable.world",
19
12
  "license": "Apache-2.0",
20
- "dependencies": {
21
- "@types/react": "*",
22
- "@types/react-dom": "*",
23
- "@vue/runtime-core": "*"
13
+ "peerDependencies": {
14
+ "@types/react": "16-18",
15
+ "@types/react-dom": "16-18",
16
+ "@vue/runtime-core": "3"
17
+ },
18
+ "peerDependenciesMeta": {
19
+ "@types/react": {"optional": true},
20
+ "@types/react-dom": {"optional": true},
21
+ "@vue/runtime-core": {"optional": true}
24
22
  }
25
23
  }
@@ -37,6 +37,7 @@ export declare class Cartesian implements Projection {
37
37
  private _cycled;
38
38
  private _xRange;
39
39
  private _yRange;
40
+ readonly type = "cartesian";
40
41
  constructor(bounds: [
41
42
  LngLat,
42
43
  LngLat
@@ -5,9 +5,10 @@ import type { Projection } from "../../common/types";
5
5
  * @name projection.sphericalMercator
6
6
  * @augments Projection
7
7
  * @static
8
+ * @deprecated Use [Web Mercator package](https://www.npmjs.com/package/@mappable-world/mappable-web-mercator-projection) instead.
8
9
  * @example
9
10
  * ```js
10
- * const { SphericalMercator } = await mappable.import('@mappable-world/mappable-spherical-mercator-projection@0.0.1');
11
+ * const {SphericalMercator} = await mappable.import('@mappable-world/mappable-spherical-mercator-projection@0.0.1');
11
12
  * // Create a map in the spherical Mercator projection
12
13
  * const map = new mappable.MMap(document.getElementById('MMapsID'), {
13
14
  * location: {
@@ -38,7 +38,7 @@ export interface ReactifyModule {
38
38
  }
39
39
  export type GetReactContext<TContext extends Context<unknown>> = (context?: TContext | undefined) => React.Context<unknown>;
40
40
  export type ReactifiedModule<TModule extends BaseModule> = {
41
- [Property in keyof TModule]: TModule[Property] extends EntityConstructor<GenericEntity<unknown>> ? ReturnType<InternalReactifyEntity<TModule[Property]>> : TModule[Property] extends typeof Context ? ReturnType<GetReactContext<TModule[Property]>> : TModule[Property];
41
+ [Property in keyof TModule]: TModule[Property] extends EntityConstructor<GenericEntity<unknown>> ? ReturnType<InternalReactifyEntity<TModule[Property]>> : TModule[Property] extends Context<any> ? ReturnType<GetReactContext<TModule[Property]>> : TModule[Property];
42
42
  };
43
43
  export type BaseModule = Record<string | symbol, unknown>;
44
44
  export type Prettify<T> = {