@mappedin/react-native-sdk 3.4.4 → 4.0.4-alpha.8

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 (171) hide show
  1. package/README.md +12 -8
  2. package/dist/index.d.ts +5753 -0
  3. package/dist/index.js +3552 -0
  4. package/dist/index.js.map +7 -0
  5. package/package.json +26 -22
  6. package/CHANGELOG.md +0 -42
  7. package/dist/get-venue/package.json +0 -44
  8. package/dist/get-venue/src/Mappedin.API.types.d.ts +0 -203
  9. package/dist/get-venue/src/Mappedin.API.types.d.ts.map +0 -1
  10. package/dist/get-venue/src/Mappedin.API.types.js +0 -4
  11. package/dist/get-venue/src/Mappedin.d.ts +0 -256
  12. package/dist/get-venue/src/Mappedin.d.ts.map +0 -1
  13. package/dist/get-venue/src/Mappedin.js +0 -248
  14. package/dist/get-venue/src/Mappedin.types.d.ts +0 -30
  15. package/dist/get-venue/src/Mappedin.types.d.ts.map +0 -1
  16. package/dist/get-venue/src/Mappedin.types.js +0 -1
  17. package/dist/get-venue/src/MappedinCategory.d.ts +0 -48
  18. package/dist/get-venue/src/MappedinCategory.d.ts.map +0 -1
  19. package/dist/get-venue/src/MappedinCategory.js +0 -87
  20. package/dist/get-venue/src/MappedinCoordinate.d.ts +0 -42
  21. package/dist/get-venue/src/MappedinCoordinate.d.ts.map +0 -1
  22. package/dist/get-venue/src/MappedinCoordinate.js +0 -43
  23. package/dist/get-venue/src/MappedinCoordinate.test.d.ts +0 -2
  24. package/dist/get-venue/src/MappedinCoordinate.test.d.ts.map +0 -1
  25. package/dist/get-venue/src/MappedinCoordinate.test.js +0 -19
  26. package/dist/get-venue/src/MappedinDestinationSet.d.ts +0 -8
  27. package/dist/get-venue/src/MappedinDestinationSet.d.ts.map +0 -1
  28. package/dist/get-venue/src/MappedinDestinationSet.js +0 -6
  29. package/dist/get-venue/src/MappedinDirections.d.ts +0 -56
  30. package/dist/get-venue/src/MappedinDirections.d.ts.map +0 -1
  31. package/dist/get-venue/src/MappedinDirections.js +0 -42
  32. package/dist/get-venue/src/MappedinEvent.d.ts +0 -30
  33. package/dist/get-venue/src/MappedinEvent.d.ts.map +0 -1
  34. package/dist/get-venue/src/MappedinEvent.js +0 -67
  35. package/dist/get-venue/src/MappedinJSONScene.d.ts +0 -9
  36. package/dist/get-venue/src/MappedinJSONScene.d.ts.map +0 -1
  37. package/dist/get-venue/src/MappedinJSONScene.js +0 -24
  38. package/dist/get-venue/src/MappedinLocation.d.ts +0 -89
  39. package/dist/get-venue/src/MappedinLocation.d.ts.map +0 -1
  40. package/dist/get-venue/src/MappedinLocation.js +0 -223
  41. package/dist/get-venue/src/MappedinLocationRankings.d.ts +0 -12
  42. package/dist/get-venue/src/MappedinLocationRankings.d.ts.map +0 -1
  43. package/dist/get-venue/src/MappedinLocationRankings.js +0 -26
  44. package/dist/get-venue/src/MappedinLocationState.d.ts +0 -14
  45. package/dist/get-venue/src/MappedinLocationState.d.ts.map +0 -1
  46. package/dist/get-venue/src/MappedinLocationState.js +0 -33
  47. package/dist/get-venue/src/MappedinMap.d.ts +0 -64
  48. package/dist/get-venue/src/MappedinMap.d.ts.map +0 -1
  49. package/dist/get-venue/src/MappedinMap.js +0 -215
  50. package/dist/get-venue/src/MappedinMapGroup.d.ts +0 -23
  51. package/dist/get-venue/src/MappedinMapGroup.d.ts.map +0 -1
  52. package/dist/get-venue/src/MappedinMapGroup.js +0 -62
  53. package/dist/get-venue/src/MappedinNavigatable.d.ts +0 -38
  54. package/dist/get-venue/src/MappedinNavigatable.d.ts.map +0 -1
  55. package/dist/get-venue/src/MappedinNavigatable.js +0 -82
  56. package/dist/get-venue/src/MappedinNode.d.ts +0 -65
  57. package/dist/get-venue/src/MappedinNode.d.ts.map +0 -1
  58. package/dist/get-venue/src/MappedinNode.js +0 -153
  59. package/dist/get-venue/src/MappedinPolygon.d.ts +0 -60
  60. package/dist/get-venue/src/MappedinPolygon.d.ts.map +0 -1
  61. package/dist/get-venue/src/MappedinPolygon.js +0 -164
  62. package/dist/get-venue/src/MappedinRankings.d.ts +0 -32
  63. package/dist/get-venue/src/MappedinRankings.d.ts.map +0 -1
  64. package/dist/get-venue/src/MappedinRankings.js +0 -46
  65. package/dist/get-venue/src/MappedinTheme.d.ts +0 -15
  66. package/dist/get-venue/src/MappedinTheme.d.ts.map +0 -1
  67. package/dist/get-venue/src/MappedinTheme.js +0 -41
  68. package/dist/get-venue/src/MappedinVenue.d.ts +0 -47
  69. package/dist/get-venue/src/MappedinVenue.d.ts.map +0 -1
  70. package/dist/get-venue/src/MappedinVenue.js +0 -61
  71. package/dist/get-venue/src/MappedinVortex.d.ts +0 -26
  72. package/dist/get-venue/src/MappedinVortex.d.ts.map +0 -1
  73. package/dist/get-venue/src/MappedinVortex.js +0 -54
  74. package/dist/get-venue/src/default-things.d.ts +0 -14
  75. package/dist/get-venue/src/default-things.d.ts.map +0 -1
  76. package/dist/get-venue/src/default-things.js +0 -60
  77. package/dist/get-venue/src/fixtures/MappedinDemoMall.json +0 -1
  78. package/dist/get-venue/src/index.cjs.js +0 -16
  79. package/dist/get-venue/src/index.d.ts +0 -65
  80. package/dist/get-venue/src/index.d.ts.map +0 -1
  81. package/dist/get-venue/src/index.js +0 -16
  82. package/dist/get-venue/src/utils.d.ts +0 -15
  83. package/dist/get-venue/src/utils.d.ts.map +0 -1
  84. package/dist/get-venue/src/utils.js +0 -188
  85. package/dist/get-venue/tsconfig.docs.json +0 -7
  86. package/dist/get-venue/tsconfig.isomorphic.json +0 -20
  87. package/dist/get-venue/tsconfig.isomorphic.tsbuildinfo +0 -2262
  88. package/dist/get-venue/tsconfig.json +0 -19
  89. package/dist/get-venue/tsconfig.tsbuildinfo +0 -2758
  90. package/dist/sdk/src/MappedinController.d.ts +0 -45
  91. package/dist/sdk/src/MappedinController.d.ts.map +0 -1
  92. package/dist/sdk/src/MappedinController.js +0 -1
  93. package/dist/sdk/src/MiMapView.d.ts +0 -80
  94. package/dist/sdk/src/MiMapView.d.ts.map +0 -1
  95. package/dist/sdk/src/MiMapView.element.d.ts +0 -8
  96. package/dist/sdk/src/MiMapView.element.d.ts.map +0 -1
  97. package/dist/sdk/src/MiMapView.element.js +0 -5
  98. package/dist/sdk/src/MiMapView.element.web.d.ts +0 -6
  99. package/dist/sdk/src/MiMapView.element.web.d.ts.map +0 -1
  100. package/dist/sdk/src/MiMapView.element.web.js +0 -1
  101. package/dist/sdk/src/MiMapView.js +0 -1
  102. package/dist/sdk/src/MiMapView.store.d.ts +0 -197
  103. package/dist/sdk/src/MiMapView.store.d.ts.map +0 -1
  104. package/dist/sdk/src/MiMapView.store.js +0 -1
  105. package/dist/sdk/src/MiMapView.store.types.d.ts +0 -202
  106. package/dist/sdk/src/MiMapView.store.types.d.ts.map +0 -1
  107. package/dist/sdk/src/MiMapView.store.types.js +0 -1
  108. package/dist/sdk/src/MiMiniMap.d.ts +0 -31
  109. package/dist/sdk/src/MiMiniMap.d.ts.map +0 -1
  110. package/dist/sdk/src/MiMiniMap.js +0 -3
  111. package/dist/sdk/src/MiMiniMap.store.d.ts +0 -22
  112. package/dist/sdk/src/MiMiniMap.store.d.ts.map +0 -1
  113. package/dist/sdk/src/MiMiniMap.store.js +0 -1
  114. package/dist/sdk/src/assets/index.html.d.ts +0 -3
  115. package/dist/sdk/src/assets/index.html.d.ts.map +0 -1
  116. package/dist/sdk/src/assets/index.html.js +0 -1
  117. package/dist/sdk/src/index.d.ts +0 -186
  118. package/dist/sdk/src/index.d.ts.map +0 -1
  119. package/dist/sdk/src/index.js +0 -1
  120. package/dist/sdk/src/pub-sub.d.ts +0 -27
  121. package/dist/sdk/src/pub-sub.d.ts.map +0 -1
  122. package/dist/sdk/src/pub-sub.js +0 -1
  123. package/dist/sdk/src/utils.d.ts +0 -18
  124. package/dist/sdk/src/utils.d.ts.map +0 -1
  125. package/dist/sdk/src/utils.js +0 -1
  126. package/dist/sdk/tsconfig.build.tsbuildinfo +0 -6928
  127. package/dist/types/src/Mappedin.bridge.events.d.ts +0 -74
  128. package/dist/types/src/Mappedin.bridge.events.d.ts.map +0 -1
  129. package/dist/types/src/Mappedin.bridge.events.js +0 -1
  130. package/dist/types/src/index.d.ts +0 -4
  131. package/dist/types/src/index.d.ts.map +0 -1
  132. package/dist/types/src/index.js +0 -1
  133. package/dist/types/src/navigator.d.ts +0 -78
  134. package/dist/types/src/navigator.d.ts.map +0 -1
  135. package/dist/types/src/navigator.js +0 -1
  136. package/dist/types/tsconfig.tsbuildinfo +0 -1819
  137. package/dist/types_mappedin__mappedin-js/tsconfig.tsbuildinfo +0 -1781
  138. package/dist/types_mappedin__mappedin-js/types.d.ts +0 -205
  139. package/dist/types_mappedin__mappedin-js/types.d.ts.map +0 -1
  140. package/dist/types_mappedin__mappedin-js/types.js +0 -53
  141. package/docs/assets/css/main.css +0 -2660
  142. package/docs/assets/images/icons.png +0 -0
  143. package/docs/assets/images/icons@2x.png +0 -0
  144. package/docs/assets/images/widgets.png +0 -0
  145. package/docs/assets/images/widgets@2x.png +0 -0
  146. package/docs/assets/js/main.js +0 -248
  147. package/docs/assets/js/search.js +0 -1
  148. package/docs/classes/mappedin.html +0 -560
  149. package/docs/classes/mappedincategory.html +0 -373
  150. package/docs/classes/mappedindestinationset.html +0 -184
  151. package/docs/classes/mappedindirections.html +0 -258
  152. package/docs/classes/mappedinevent.html +0 -387
  153. package/docs/classes/mappedinlocation.html +0 -942
  154. package/docs/classes/mappedinmap.html +0 -501
  155. package/docs/classes/mappedinmapgroup.html +0 -329
  156. package/docs/classes/mappedinnode.html +0 -717
  157. package/docs/classes/mappedinpolygon.html +0 -714
  158. package/docs/classes/mappedinrankings.html +0 -288
  159. package/docs/classes/mappedinvenue.html +0 -494
  160. package/docs/classes/mappedinvortex.html +0 -331
  161. package/docs/classes/mapviewstore.html +0 -1233
  162. package/docs/enums/action_type.html +0 -188
  163. package/docs/enums/bearing_type.html +0 -188
  164. package/docs/enums/collision_ranking_tiers.html +0 -177
  165. package/docs/enums/e_bluedot_state.html +0 -223
  166. package/docs/enums/e_bluedot_state_reason.html +0 -197
  167. package/docs/enums/e_marker_state.html +0 -204
  168. package/docs/enums/marker_anchor.html +0 -188
  169. package/docs/enums/state.html +0 -160
  170. package/docs/index.html +0 -1078
  171. package/docs/modules.html +0 -1898
@@ -1,215 +0,0 @@
1
- import { LatLonSpherical } from 'geodesy';
2
- import { MappedinCoordinate } from './MappedinCoordinate';
3
- import { addToSet, getArray, getMapScale } from './utils';
4
- const PREFETCH_SCENES = true;
5
- /**
6
- * A {@link MappedinMap} belonging to a specific {@link MappedinVenue}. Typically represents a certain floor. Give this to a {@link MiMapView} to display to the user.
7
- *
8
- * A Map can have more properties such as 'elevation', 'name' (e.g. Level 1), and 'shortName' (e.g. L1). The elevation property can be used to determine the order of the floors (first, second, etc). Elevation is 0 based, going up and down in integers representing the number of floors above or below 0, which is ground level.
9
- *
10
- * The {@link Mappedin} 'things' object is where you would specify what properties you want to download for Maps. Only specify what you will actually use, to minmimze transfer time. Work with your Mappedin developer relations contact to set up any custom properties you need.
11
- *
12
- * See below for an example a 'things' object with available Map properties specified:
13
- *
14
- * things: {
15
- * venue: [],
16
- * locations: [],
17
- * categories: [],
18
- * maps: ['name', 'elevation', 'shortName']
19
- * }
20
- *
21
- * @class MappedinMap
22
- */
23
- export class MappedinMap {
24
- constructor(mappedin, data) {
25
- this.#cache = {};
26
- this.id = '';
27
- this.group = '';
28
- this.name = '';
29
- this.shortName = '';
30
- this.scale = 0;
31
- this.georeference = [];
32
- this._scale = 0;
33
- this.#mappedin = mappedin;
34
- this.#data = data;
35
- Object.assign(this, data);
36
- // @ts-ignore
37
- this._scale = getMapScale(this);
38
- this.scale = this.x_scale;
39
- }
40
- #mappedin;
41
- #cache;
42
- #data;
43
- /**
44
- * Polygons on this Map.
45
- *
46
- * @property polygons {[MappedinPolygon]}
47
- */
48
- get polygons() {
49
- const cache = this.#cache.polygons;
50
- if (typeof cache !== 'undefined') {
51
- return cache;
52
- }
53
- const related = [];
54
- const { polygons } = this.#mappedin;
55
- const { id } = this;
56
- for (let i = 0, iLen = polygons.length; i < iLen; ++i) {
57
- const polygon = polygons[i];
58
- if (polygon.map === id) {
59
- related.push(polygon);
60
- }
61
- }
62
- this.#cache.polygons = related;
63
- return related;
64
- }
65
- /**
66
- * Map Group this map belongs to.
67
- *
68
- * @property mapGroup {MappedinMapGroup}
69
- */
70
- get mapGroup() {
71
- const cache = this.#cache.mapGroup;
72
- if (typeof cache !== 'undefined') {
73
- return cache;
74
- }
75
- const id = this.group;
76
- const related = (id && this.#mappedin._mapGroupsById[id]) || null;
77
- this.#cache.mapGroup = related;
78
- return related;
79
- }
80
- /**
81
- * Create coordinate using lat/lon
82
- *
83
- * @param lat latitude of coordinate
84
- * @param lon longitude of coordinate
85
- */
86
- createCoordinate(lat, lon) {
87
- // let's grab a reference point
88
- const anchor = this.georeference[0];
89
- const anchorLatLon = new LatLonSpherical(anchor.target.x, anchor.target.y);
90
- const targetLatLon = new LatLonSpherical(lat, lon);
91
- // get distance between reference point and target lat/lon
92
- const worldDistance = anchorLatLon.distanceTo(targetLatLon);
93
- // get bearing (direction) between reference point and target point
94
- const worldBearing = (((anchorLatLon.finalBearingTo(targetLatLon) + 360) % 360) * Math.PI) /
95
- 180;
96
- // get distance in mappedin units
97
- const mappedinDistance = worldDistance * (1 / this.scale);
98
- // add bearing to map rotation relative to north
99
- const mappedinBearing = worldBearing + this.getNorth();
100
- // get deltas of distance and bearing
101
- const deltaX = Math.sin(mappedinBearing) * mappedinDistance;
102
- const deltaY = Math.cos(mappedinBearing) * mappedinDistance;
103
- return new MappedinCoordinate(lat, lon, anchor.control.x + deltaX, anchor.control.y - deltaY, this.id);
104
- }
105
- /**
106
- *
107
- * @returns map rotation in degrees from North
108
- */
109
- getNorth() {
110
- let north;
111
- try {
112
- // Could get the max/min and use that, to spread out any error
113
- const anchor1 = this.georeference[0];
114
- const anchor2 = this.georeference[2];
115
- const ll1 = new LatLonSpherical(anchor1.target.x, anchor1.target.y);
116
- const ll2 = new LatLonSpherical(anchor2.target.x, anchor2.target.y);
117
- const bearing = ((ll1.finalBearingTo(ll2) + (360 % 360)) * Math.PI) / 180;
118
- const angle = Math.atan2(anchor2.control.y - anchor1.control.y, anchor2.control.x - anchor1.control.x);
119
- north = -(bearing - angle - Math.PI / 2);
120
- }
121
- catch (e) {
122
- north = 0;
123
- console.warn(e);
124
- console.warn(`Couldn't georeference ${this.name || this.shortName || this.id}. Probably not enough geocoordinates.`);
125
- }
126
- return north;
127
- }
128
- static hydrate(maps, mappedin) {
129
- return maps.map((m) => new MappedinMap(mappedin, m));
130
- }
131
- static async fetch(mappedin) {
132
- const fields = mappedin.options.things.maps.slice();
133
- if (mappedin.options.perspective) {
134
- addToSet(fields, 'perspectives');
135
- }
136
- if (mappedin.options.things.mapGroups) {
137
- addToSet(fields, 'group');
138
- }
139
- // Elevation is required for offline directions
140
- addToSet(fields, 'elevation');
141
- // Get modern map scale and future-proof
142
- addToSet(fields, 'x_scale');
143
- addToSet(fields, 'scale');
144
- addToSet(fields, 'georeference');
145
- const query = {
146
- fields,
147
- perspective: mappedin.options.perspective,
148
- venue: mappedin.options.venue,
149
- };
150
- try {
151
- const data = await getArray(mappedin.options, 'map', query);
152
- const setVisibleLayer = (layerName) => {
153
- const layerObject = map.layers.find((l) => l.id === layerName);
154
- if (layerObject) {
155
- layerObject.visible = true;
156
- }
157
- else {
158
- map.layers.push({ id: layerName, visible: true });
159
- }
160
- };
161
- // const promises = [];
162
- for (let i = 0, iLen = data.length; i < iLen; ++i) {
163
- var map = data[i];
164
- if (map) {
165
- const per = map.perspective;
166
- if (per != null) {
167
- map.perspectiveId = per.id;
168
- if (mappedin.options.do2D) {
169
- if (fields.indexOf('width') > -1) {
170
- map.width = (per.size && per.size.width) || per.width;
171
- }
172
- if (fields.indexOf('height') > -1) {
173
- map.height = (per.size && per.size.height) || per.height;
174
- }
175
- if (fields.indexOf('tiles') > -1) {
176
- map.tiles = per.tiles;
177
- }
178
- if (fields.indexOf('original') > -1) {
179
- map.original = per.original;
180
- }
181
- }
182
- else {
183
- // OBJ loader support
184
- if (fields.indexOf('scene') > -1) {
185
- map.scene = per.scene;
186
- }
187
- if (per.layers) {
188
- map.layers.forEach((layer) => {
189
- layer.visible = false;
190
- });
191
- per.layers.forEach(setVisibleLayer);
192
- }
193
- else {
194
- map.layers.forEach((layer) => {
195
- layer.visible = true;
196
- });
197
- }
198
- }
199
- }
200
- delete map.perspective;
201
- }
202
- data[i] = new MappedinMap(mappedin, map);
203
- }
204
- // await Promise.all(promises);
205
- return data;
206
- }
207
- catch (e) {
208
- console.error('Fetch Maps:', e);
209
- return [];
210
- }
211
- }
212
- toJSON() {
213
- return this.#data;
214
- }
215
- }
@@ -1,23 +0,0 @@
1
- import type { Mappedin } from './Mappedin';
2
- import type { MappedinMap } from './MappedinMap';
3
- /**
4
- * A {@link MappedinMapGroup} is a collection of maps, usually representing the different floors of a single building. All Maps will be in a MapGroup, but if your Venue is only a single building (like a mall) you can likely ignore MapGroups entirely.
5
- *
6
- * @class MappedinMapGroup
7
- */
8
- export declare class MappedinMapGroup {
9
- #private;
10
- id: string;
11
- name: string;
12
- constructor(mappedin: Mappedin, data: any);
13
- /**
14
- * Maps within this MapGroup.
15
- *
16
- * @property maps {[MappedinMap]}
17
- */
18
- get maps(): MappedinMap[];
19
- static hydrate(mapGroups: any, mappedin: Mappedin): MappedinMapGroup[];
20
- static fetch(mappedin: Mappedin): Promise<MappedinMapGroup[]>;
21
- toJSON(): any;
22
- }
23
- //# sourceMappingURL=MappedinMapGroup.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MappedinMapGroup.d.ts","sourceRoot":"","sources":["../../src/MappedinMapGroup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGjD;;;;GAIG;AACH,qBAAa,gBAAgB;;IAO3B,EAAE,SAAM;IAER,IAAI,SAAM;gBAEE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG;IAMzC;;;;OAIG;IACH,IAAI,IAAI,IAAI,WAAW,EAAE,CAgBxB;IAED,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,GAAG,gBAAgB,EAAE;WAIzD,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAenE,MAAM;CAGP"}
@@ -1,62 +0,0 @@
1
- import { getArray } from './utils';
2
- /**
3
- * A {@link MappedinMapGroup} is a collection of maps, usually representing the different floors of a single building. All Maps will be in a MapGroup, but if your Venue is only a single building (like a mall) you can likely ignore MapGroups entirely.
4
- *
5
- * @class MappedinMapGroup
6
- */
7
- export class MappedinMapGroup {
8
- constructor(mappedin, data) {
9
- this.#cache = {};
10
- this.id = '';
11
- this.name = '';
12
- this.#data = data;
13
- this.#mappedin = mappedin;
14
- Object.assign(this, data);
15
- }
16
- #mappedin;
17
- #data;
18
- #cache;
19
- /**
20
- * Maps within this MapGroup.
21
- *
22
- * @property maps {[MappedinMap]}
23
- */
24
- get maps() {
25
- const cache = this.#cache.maps;
26
- if (typeof cache !== 'undefined') {
27
- return cache;
28
- }
29
- const related = [];
30
- const { maps } = this.#mappedin;
31
- const { id } = this.#data;
32
- for (let i = 0, iLen = maps.length; i < iLen; ++i) {
33
- const map = maps[i];
34
- if (map.group === id) {
35
- related.push(map);
36
- }
37
- }
38
- this.#cache.maps = related;
39
- return related;
40
- }
41
- static hydrate(mapGroups, mappedin) {
42
- return mapGroups.map((mg) => new MappedinMapGroup(mappedin, mg));
43
- }
44
- static async fetch(mappedin) {
45
- const fields = mappedin.options.things.mapGroups.slice();
46
- const query = {
47
- fields,
48
- venue: mappedin.options.venue,
49
- };
50
- try {
51
- const data = await getArray(mappedin.options, 'map-group', query);
52
- return data.map((mg) => new MappedinMapGroup(mappedin, mg));
53
- }
54
- catch (e) {
55
- console.error('Fetch Map Groups:', e);
56
- return [];
57
- }
58
- }
59
- toJSON() {
60
- return this.#data;
61
- }
62
- }
@@ -1,38 +0,0 @@
1
- import type { MappedinLocation } from './MappedinLocation';
2
- import type { MappedinPolygon } from './MappedinPolygon';
3
- import type { MappedinNode } from './MappedinNode';
4
- import { MappedinDestinationSet } from './MappedinDestinationSet';
5
- import type { Mappedin } from './Mappedin';
6
- import { MappedinDirections } from './MappedinDirections';
7
- export declare type TDirectionToOptions = {
8
- accessible?: boolean;
9
- };
10
- export declare abstract class MappedinNavigatable {
11
- #private;
12
- constructor(mappedin: Mappedin);
13
- /**
14
- *
15
- * Get Directions to a node, polygon, or location
16
- */
17
- directionsTo(destination: MappedinNode | MappedinLocation | MappedinPolygon, options: TDirectionToOptions, cb?: (error: any, directions: MappedinDirections | undefined) => void): MappedinDirections | undefined;
18
- directionsTo(destination: MappedinDestinationSet, options: TDirectionToOptions, cb?: (error: any, directions: MappedinDirections | undefined) => void): MappedinDirections[] | undefined;
19
- /**
20
- *
21
- * Calculate distance between 2 nodes, polygons or locations
22
- */
23
- distanceTo(destination: MappedinNode | MappedinLocation | MappedinPolygon, options: TDirectionToOptions,
24
- /**
25
- * @deprecated
26
- */
27
- cb?: (error: any, distance: number) => void): number;
28
- /**
29
- *
30
- * @deprecated
31
- */
32
- directionsToCallback(destination: MappedinNode | MappedinLocation | MappedinPolygon, options: TDirectionToOptions,
33
- /**
34
- * @deprecated
35
- */
36
- cb?: (error: any, directions: MappedinDirections | undefined) => void): MappedinDirections | undefined;
37
- }
38
- //# sourceMappingURL=MappedinNavigatable.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MappedinNavigatable.d.ts","sourceRoot":"","sources":["../../src/MappedinNavigatable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,oBAAY,mBAAmB,GAAG;IAChC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,8BAAsB,mBAAmB;;gBAG3B,QAAQ,EAAE,QAAQ;IAI9B;;;OAGG;IACH,YAAY,CACV,WAAW,EAAE,YAAY,GAAG,gBAAgB,GAAG,eAAe,EAC9D,OAAO,EAAE,mBAAmB,EAC5B,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,kBAAkB,GAAG,SAAS,KAAK,IAAI,GACpE,kBAAkB,GAAG,SAAS;IACjC,YAAY,CACV,WAAW,EAAE,sBAAsB,EACnC,OAAO,EAAE,mBAAmB,EAC5B,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,kBAAkB,GAAG,SAAS,KAAK,IAAI,GACpE,kBAAkB,EAAE,GAAG,SAAS;IA0DnC;;;OAGG;IACH,UAAU,CACR,WAAW,EAAE,YAAY,GAAG,gBAAgB,GAAG,eAAe,EAC9D,OAAO,EAAE,mBAAmB;IAC5B;;OAEG;IACH,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,GAC1C,MAAM;IAaT;;;OAGG;IACH,oBAAoB,CAClB,WAAW,EAAE,YAAY,GAAG,gBAAgB,GAAG,eAAe,EAC9D,OAAO,EAAE,mBAAmB;IAC5B;;OAEG;IACH,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,kBAAkB,GAAG,SAAS,KAAK,IAAI,GACpE,kBAAkB,GAAG,SAAS;CAWlC"}
@@ -1,82 +0,0 @@
1
- import { MappedinDestinationSet } from './MappedinDestinationSet';
2
- import { getNodesForNavigatable } from './utils';
3
- import { MappedinDirections } from './MappedinDirections';
4
- export class MappedinNavigatable {
5
- constructor(mappedin) {
6
- this.#mappedin = mappedin;
7
- }
8
- #mappedin;
9
- directionsTo(destination, options, cb) {
10
- if (destination instanceof MappedinDestinationSet) {
11
- // multiple
12
- let allDirections = [];
13
- let currentStepDeparture = this;
14
- for (let i = 0; i < destination.destinations.length; i++) {
15
- const currentStepDestination = destination.destinations[i];
16
- const departureNodes = getNodesForNavigatable(currentStepDeparture);
17
- const destinationNodes = getNodesForNavigatable(currentStepDestination);
18
- const directionsObject = this.#mappedin.navigator.getDirections({
19
- originIds: departureNodes,
20
- destinationNodeIds: destinationNodes,
21
- accessible: options?.accessible || false,
22
- });
23
- const directions = new MappedinDirections(this.#mappedin, directionsObject);
24
- allDirections.push(directions);
25
- currentStepDeparture = currentStepDestination;
26
- }
27
- return allDirections;
28
- }
29
- else {
30
- // single
31
- const departureNodes = getNodesForNavigatable(this);
32
- const destinationNodes = getNodesForNavigatable(destination);
33
- const directionsObject = this.#mappedin.navigator.getDirections({
34
- originIds: departureNodes,
35
- destinationNodeIds: destinationNodes,
36
- accessible: options?.accessible || false,
37
- });
38
- const directions = new MappedinDirections(this.#mappedin, directionsObject);
39
- if (typeof cb === 'function') {
40
- cb(null, directions);
41
- }
42
- else {
43
- return directions;
44
- }
45
- }
46
- }
47
- /**
48
- *
49
- * Calculate distance between 2 nodes, polygons or locations
50
- */
51
- distanceTo(destination, options,
52
- /**
53
- * @deprecated
54
- */
55
- cb) {
56
- const directions = this.directionsTo(destination, options);
57
- if (typeof cb === 'function') {
58
- cb(null, directions?.distance || 0);
59
- }
60
- else {
61
- return directions?.distance || 0;
62
- }
63
- return 0;
64
- }
65
- /**
66
- *
67
- * @deprecated
68
- */
69
- directionsToCallback(destination, options,
70
- /**
71
- * @deprecated
72
- */
73
- cb) {
74
- const directions = this.directionsTo(destination, options);
75
- if (typeof cb === 'function') {
76
- cb(null, directions);
77
- }
78
- else {
79
- return directions;
80
- }
81
- }
82
- }
@@ -1,65 +0,0 @@
1
- import type { MappedinPolygon } from './MappedinPolygon';
2
- import type { Mappedin } from './Mappedin';
3
- import type { MappedinLocation } from './MappedinLocation';
4
- import type { TOpeningHours } from './Mappedin.API.types';
5
- import { MappedinNavigatable } from './MappedinNavigatable';
6
- /**
7
- * A {@link MappedinNode} represents a position, anchored to a specific {@link MappedinMap}.
8
- *
9
- * A Node can have more properties but usually the default is sufficient. The {@link Mappedin} 'things' object is where you would specify what properties you want to download for Nodes. Only specify what you will actually use, to minmimze transfer time. Work with your Mappedin developer relations contact to set up any custom properties you need.
10
- *
11
- * @class MappedinNode
12
- */
13
- export declare class MappedinNode extends MappedinNavigatable {
14
- #private;
15
- /**
16
- * Node ID.
17
- * @property id {string}
18
- */
19
- id: string;
20
- /**
21
- * ID of Map that the Node is located on.
22
- *
23
- * @property map {string}
24
- */
25
- map: string;
26
- /**
27
- * X coordinate of Node's position.
28
- * @property x {number}
29
- */
30
- x: number;
31
- /**
32
- * Y coordinate of Node's position.
33
- * @property y {number}
34
- */
35
- y: number;
36
- /**
37
- * Operation Hours of this node. A Location may have different operation hours per node, for example 2 washrooms
38
- */
39
- operationHours?: TOpeningHours[];
40
- externalId?: string;
41
- constructor(mappedin: Mappedin, data: any);
42
- /**
43
- * Adjacent Nodes.
44
- *
45
- * @property paths
46
- * @type [MappedinNode]
47
- */
48
- get paths(): MappedinNode[];
49
- set paths(paths: MappedinNode[]);
50
- /**
51
- * Locations attached to this Node.
52
- *
53
- * @property locations
54
- * @type [MappedinLocation]
55
- */
56
- get locations(): MappedinLocation[];
57
- /**
58
- * Polygon that this node is part of
59
- */
60
- get polygon(): MappedinPolygon;
61
- static hydrate(nodes: any, mappedin: Mappedin): MappedinNode[];
62
- static fetch(mappedin: Mappedin): Promise<MappedinNode[]>;
63
- toJSON(): any;
64
- }
65
- //# sourceMappingURL=MappedinNode.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MappedinNode.d.ts","sourceRoot":"","sources":["../../src/MappedinNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG5D;;;;;;GAMG;AACH,qBAAa,YAAa,SAAQ,mBAAmB;;IAQnD;;;OAGG;IACH,EAAE,SAAM;IAER;;;;OAIG;IACH,GAAG,SAAM;IAET;;;OAGG;IACH,CAAC,SAAK;IAEN;;;OAGG;IACH,CAAC,SAAK;IAEN;;OAEG;IACH,cAAc,CAAC,EAAE,aAAa,EAAE,CAAC;IAEjC,UAAU,CAAC,EAAE,MAAM,CAAC;gBAER,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG;IASzC;;;;;OAKG;IACH,IAAI,KAAK,IAAI,YAAY,EAAE,CAmB1B;IAED,IAAI,KAAK,CAAC,KAAK,EArBF,YAAY,EAqBV,EAEd;IAED;;;;;OAKG;IACH,IAAI,SAAS,IAAI,gBAAgB,EAAE,CAuBlC;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,eAAe,CAgB7B;IAED,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,GAAG,YAAY,EAAE;WAIjD,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IA2B/D,MAAM;CAGP"}
@@ -1,153 +0,0 @@
1
- import { MappedinNavigatable } from './MappedinNavigatable';
2
- import { addToSet, getArray } from './utils';
3
- /**
4
- * A {@link MappedinNode} represents a position, anchored to a specific {@link MappedinMap}.
5
- *
6
- * A Node can have more properties but usually the default is sufficient. The {@link Mappedin} 'things' object is where you would specify what properties you want to download for Nodes. Only specify what you will actually use, to minmimze transfer time. Work with your Mappedin developer relations contact to set up any custom properties you need.
7
- *
8
- * @class MappedinNode
9
- */
10
- export class MappedinNode extends MappedinNavigatable {
11
- constructor(mappedin, data) {
12
- super(mappedin);
13
- this.#cache = {};
14
- // #index;
15
- /**
16
- * Node ID.
17
- * @property id {string}
18
- */
19
- this.id = '';
20
- /**
21
- * ID of Map that the Node is located on.
22
- *
23
- * @property map {string}
24
- */
25
- this.map = '';
26
- /**
27
- * X coordinate of Node's position.
28
- * @property x {number}
29
- */
30
- this.x = 0;
31
- /**
32
- * Y coordinate of Node's position.
33
- * @property y {number}
34
- */
35
- this.y = 0;
36
- this.#mappedin = mappedin;
37
- this.#data = data;
38
- Object.assign(this, data);
39
- }
40
- #mappedin;
41
- #data;
42
- #cache;
43
- #paths;
44
- /**
45
- * Adjacent Nodes.
46
- *
47
- * @property paths
48
- * @type [MappedinNode]
49
- */
50
- get paths() {
51
- const cache = this.#cache.paths;
52
- if (typeof cache !== 'undefined') {
53
- return cache;
54
- }
55
- const related = [];
56
- const index = this.#mappedin._nodesById;
57
- const through = this.#paths;
58
- if (Array.isArray(through)) {
59
- for (let i = 0, iLen = through.length; i < iLen; ++i) {
60
- const nodeId = through[i].node;
61
- const node = index[nodeId];
62
- if (node != null) {
63
- related.push(node);
64
- }
65
- }
66
- }
67
- this.#cache.paths = related;
68
- return related;
69
- }
70
- set paths(paths) {
71
- this.#paths = paths;
72
- }
73
- /**
74
- * Locations attached to this Node.
75
- *
76
- * @property locations
77
- * @type [MappedinLocation]
78
- */
79
- get locations() {
80
- const cache = this.#cache.locations;
81
- if (typeof cache !== 'undefined') {
82
- return cache;
83
- }
84
- const related = [];
85
- const { locations } = this.#mappedin;
86
- const nodeId = this.id;
87
- for (let i = 0, iLen = locations.length; i < iLen; ++i) {
88
- const location = locations[i];
89
- const through = location.nodes;
90
- if (Array.isArray(through)) {
91
- for (let j = 0, jLen = through.length; j < jLen; ++j) {
92
- const tuple = through[j];
93
- if (tuple.id === nodeId) {
94
- related.push(location);
95
- break;
96
- }
97
- }
98
- }
99
- }
100
- this.#cache.locations = related;
101
- return related;
102
- }
103
- /**
104
- * Polygon that this node is part of
105
- */
106
- get polygon() {
107
- const cache = this.#cache.polygon;
108
- if (typeof cache !== 'undefined') {
109
- return cache;
110
- }
111
- let polygonContainingThisNode;
112
- const { polygons } = this.#mappedin;
113
- const nodeId = this.id;
114
- for (let i = 0, iLen = polygons.length; i < iLen; ++i) {
115
- const polygon = polygons[i];
116
- if (polygon.entrances.map((e) => e.id).includes(nodeId)) {
117
- polygonContainingThisNode = polygon;
118
- }
119
- }
120
- this.#cache.polygon = polygonContainingThisNode;
121
- return polygonContainingThisNode;
122
- }
123
- static hydrate(nodes, mappedin) {
124
- return nodes.map((n) => new MappedinNode(mappedin, n));
125
- }
126
- static async fetch(mappedin) {
127
- const fields = mappedin.options.things.nodes.slice();
128
- if (mappedin.options.things.maps) {
129
- addToSet(fields, 'map');
130
- }
131
- // Some fields are required for offline directions
132
- const requiredFields = ['weight', 'multiplier', 'accessible'];
133
- requiredFields.forEach(function (field) {
134
- addToSet(fields, field);
135
- });
136
- const query = {
137
- fields,
138
- perspective: (mappedin.options.do2D && mappedin.options.perspective) || undefined,
139
- venue: mappedin.options.venue,
140
- };
141
- try {
142
- const data = await getArray(mappedin.options, 'node', query);
143
- return data.map((n) => new MappedinNode(mappedin, n));
144
- }
145
- catch (e) {
146
- console.error('Fetch Nodes:', e);
147
- return [];
148
- }
149
- }
150
- toJSON() {
151
- return this.#data;
152
- }
153
- }