@mappedin/react-native-sdk 5.0.0-beta.8 → 5.0.0
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 +5 -576
- package/dist/index.d.ts +4840 -5155
- package/dist/index.js +202 -201
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
## Resources
|
|
4
4
|
- [Mappedin Developer Portal](https://developer.mappedin.com)
|
|
5
|
-
- [React Native SDK
|
|
6
|
-
- [Release notes](https://developer.mappedin.com/
|
|
7
|
-
- [Migration guide to
|
|
8
|
-
- [API Reference](https://developer.mappedin.com/
|
|
5
|
+
- [React Native SDK V5 guides](https://developer.mappedin.com/react-native-sdk/v5/)
|
|
6
|
+
- [Release notes](https://developer.mappedin.com/react-native-sdk/v5/release-notes)
|
|
7
|
+
- [Migration guide to V5](https://developer.mappedin.com/react-native-sdk/v5/migration-guide)
|
|
8
|
+
- [API Reference](https://developer.mappedin.com/react-native-sdk-api/v5/latest)
|
|
9
9
|
- [Trial Keys](https://developer.mappedin.com/guides/api-keys)
|
|
10
10
|
|
|
11
11
|
## Installation
|
|
@@ -90,314 +90,7 @@ const App = () => {
|
|
|
90
90
|
};
|
|
91
91
|
```
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
It is possible to fetch venue data (locations, maps, etc), outside of the MiMapView component. This can be helpful for cases where a map isn't always needed or there is a need to fetch the data first, and render the map later.
|
|
96
|
-
|
|
97
|
-
```tsx
|
|
98
|
-
|
|
99
|
-
import { getVenue, MiMapView } from '@mappedin/react-native-sdk';
|
|
100
|
-
|
|
101
|
-
const options = {
|
|
102
|
-
clientId: '****',
|
|
103
|
-
clientSecret: '***',
|
|
104
|
-
venue: 'venue-slug',
|
|
105
|
-
perspective: 'Website',
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
const App = () => {
|
|
109
|
-
const [venueData, setVenueData] = React.useState<Mappedin>({});
|
|
110
|
-
|
|
111
|
-
useEffect(() => {
|
|
112
|
-
async function init() {
|
|
113
|
-
const venueData = await getVenue(options);
|
|
114
|
-
console.log(venueData.locations);
|
|
115
|
-
setVenueData(venueData);
|
|
116
|
-
}
|
|
117
|
-
}, []);
|
|
118
|
-
|
|
119
|
-
return (
|
|
120
|
-
{venueData != null &&
|
|
121
|
-
<MiMapView
|
|
122
|
-
style={{ flex: 1 }}
|
|
123
|
-
options={options}
|
|
124
|
-
// pass venueData in
|
|
125
|
-
venueData={venueData}
|
|
126
|
-
/>
|
|
127
|
-
}
|
|
128
|
-
);
|
|
129
|
-
};
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
### Listen to polygon clicks
|
|
133
|
-
|
|
134
|
-
```tsx
|
|
135
|
-
import { MiMapView } from '@mappedin/react-native-sdk';
|
|
136
|
-
import type { MappedinLocation, Mappedin } from '@mappedin/react-native-sdk';
|
|
137
|
-
|
|
138
|
-
const App = () => {
|
|
139
|
-
const [venueData, setVenueData] = React.useState<Mappedin>({});
|
|
140
|
-
const [
|
|
141
|
-
selectedLocation,
|
|
142
|
-
setSelectedLocation,
|
|
143
|
-
] = React.useState<MappedinLocation>({});
|
|
144
|
-
|
|
145
|
-
return (
|
|
146
|
-
<MiMapView
|
|
147
|
-
style={{ flex: 1 }}
|
|
148
|
-
options={options}
|
|
149
|
-
onDataLoaded={({ venueData: Mappedin }) => {
|
|
150
|
-
setVenueData(venueData);
|
|
151
|
-
}}
|
|
152
|
-
onPolygonClicked={({ polygon }) => {
|
|
153
|
-
setSelectedLocation(polygon.locations[0]);
|
|
154
|
-
}}
|
|
155
|
-
/>
|
|
156
|
-
);
|
|
157
|
-
};
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
### Rotate the map
|
|
161
|
-
|
|
162
|
-
```tsx
|
|
163
|
-
import { MiMapView } from '@mappedin/react-native-sdk';
|
|
164
|
-
import type { MapViewStore } from '@mappedin/react-native-sdk';
|
|
165
|
-
|
|
166
|
-
// Imperative API
|
|
167
|
-
const mapView = React.useRef<MapViewStore>();
|
|
168
|
-
|
|
169
|
-
const App = () => {
|
|
170
|
-
return (
|
|
171
|
-
<MiMapView
|
|
172
|
-
style={{ flex: 1 }}
|
|
173
|
-
ref={mapView}
|
|
174
|
-
options={options}
|
|
175
|
-
onFirstMapLoaded={() => {
|
|
176
|
-
mapView.current!.Camera.set({ positionOptions: { rotation: 90 });
|
|
177
|
-
}}
|
|
178
|
-
/>
|
|
179
|
-
);
|
|
180
|
-
};
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
### Focus on the polygon and highlight it
|
|
184
|
-
|
|
185
|
-
```tsx
|
|
186
|
-
import { MiMapView } from '@mappedin/react-native-sdk';
|
|
187
|
-
import type {
|
|
188
|
-
MappedinPolygon,
|
|
189
|
-
MapViewStore,
|
|
190
|
-
Mappedin,
|
|
191
|
-
} from '@mappedin/react-native-sdk';
|
|
192
|
-
|
|
193
|
-
const App = () => {
|
|
194
|
-
const [venueData, setVenueData] = React.useState<Mappedin>({});
|
|
195
|
-
const [
|
|
196
|
-
selectedLocation,
|
|
197
|
-
setSelectedLocation,
|
|
198
|
-
] = React.useState<MappedinLocation>({});
|
|
199
|
-
|
|
200
|
-
// Imperative API
|
|
201
|
-
const mapView = React.useRef<MapViewStore>();
|
|
202
|
-
|
|
203
|
-
return (
|
|
204
|
-
<MiMapView
|
|
205
|
-
style={{ flex: 1 }}
|
|
206
|
-
ref={mapView}
|
|
207
|
-
options={options}
|
|
208
|
-
onDataLoaded={({ venueData: Mappedin }) => {
|
|
209
|
-
setVenueData(venueData);
|
|
210
|
-
}}
|
|
211
|
-
onPolygonClicked={async ({ polygon: MappedinPolygon }) => {
|
|
212
|
-
setSelectedLocation(polygon.locations[0]);
|
|
213
|
-
mapView.current.clearAllPolygonColors();
|
|
214
|
-
mapView.current.setPolygonColor(polygon, 'red');
|
|
215
|
-
// lets wait for the focusOn to complete
|
|
216
|
-
await mapView.current.Camera.focusOn({ targets: {
|
|
217
|
-
polygons: [polygon],
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
console.log('success!');
|
|
221
|
-
}}
|
|
222
|
-
/>
|
|
223
|
-
);
|
|
224
|
-
};
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
### Enable Blue Dot and listen to update events
|
|
228
|
-
|
|
229
|
-
```tsx
|
|
230
|
-
import { MiMapView } from '@mappedin/react-native-sdk';
|
|
231
|
-
import type {
|
|
232
|
-
TBlueDotUpdate,
|
|
233
|
-
MapViewStore,
|
|
234
|
-
MappedinMap,
|
|
235
|
-
MappedinNode,
|
|
236
|
-
} from '@mappedin/react-native-sdk';
|
|
237
|
-
|
|
238
|
-
// Imperative API
|
|
239
|
-
const mapView = React.useRef<MapViewStore>();
|
|
240
|
-
|
|
241
|
-
const App = () => {
|
|
242
|
-
return (
|
|
243
|
-
<MiMapView
|
|
244
|
-
style={{ flex: 1 }}
|
|
245
|
-
ref={mapView}
|
|
246
|
-
options={options}
|
|
247
|
-
onFirstMapLoaded={() => {
|
|
248
|
-
mapView.current.BlueDot.enable();
|
|
249
|
-
}}
|
|
250
|
-
onBlueDotStateChanged={({
|
|
251
|
-
stateChange,
|
|
252
|
-
}: {
|
|
253
|
-
stateChange: TBlueDotStateChange;
|
|
254
|
-
}) => {
|
|
255
|
-
// This event can be used to get real time updates as to what the nearest node is
|
|
256
|
-
const {
|
|
257
|
-
map,
|
|
258
|
-
nearestNode,
|
|
259
|
-
}: {
|
|
260
|
-
map: MappedinMap;
|
|
261
|
-
nearestNode: MappedinNode;
|
|
262
|
-
} = stateChange;
|
|
263
|
-
}}
|
|
264
|
-
/>
|
|
265
|
-
);
|
|
266
|
-
};
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
### Set SDK into "FOLLOW" mode
|
|
270
|
-
|
|
271
|
-
Setting the SDK into follow mode will lock the camera to follow the BlueDot at the center of the screen. Interacting with the map will put the SDK back into EXPLORE mode and emit onStateChanged event.
|
|
272
|
-
|
|
273
|
-
```tsx
|
|
274
|
-
import { MiMapView } from '@mappedin/react-native-sdk';
|
|
275
|
-
import type {
|
|
276
|
-
TBlueDotUpdate,
|
|
277
|
-
MapViewStore,
|
|
278
|
-
MappedinLocation,
|
|
279
|
-
MappedinNode,
|
|
280
|
-
} from '@mappedin/react-native-sdk';
|
|
281
|
-
import { STATE } from '@mappedin/react-native-sdk';
|
|
282
|
-
|
|
283
|
-
// Imperative API
|
|
284
|
-
const mapView = React.useRef<MapViewStore>();
|
|
285
|
-
const nearestNode = React.useRef<MappedinNode>();
|
|
286
|
-
const [
|
|
287
|
-
selectedLocation,
|
|
288
|
-
setSelectedLocation,
|
|
289
|
-
] = React.useState<MappedinLocation>({});
|
|
290
|
-
|
|
291
|
-
const App = () => {
|
|
292
|
-
return (
|
|
293
|
-
<>
|
|
294
|
-
<MiMapView
|
|
295
|
-
style={{ flex: 1 }}
|
|
296
|
-
ref={mapView}
|
|
297
|
-
options={options}
|
|
298
|
-
onStateChanged={({ state }) => {
|
|
299
|
-
console.log('Current State is', state);
|
|
300
|
-
}}
|
|
301
|
-
onDataLoaded={() => {
|
|
302
|
-
mapView.current.setState(STATE.FOLLOW);
|
|
303
|
-
mapView.current.BlueDot.enable();
|
|
304
|
-
}}
|
|
305
|
-
onBlueStateChanged={({ stateChange }) => {
|
|
306
|
-
nearestNode.current = stateChange.nearestNode;
|
|
307
|
-
}}
|
|
308
|
-
onPolygonClicked={({ polygon: MappedinPolygon }) => {
|
|
309
|
-
setSelectedLocation(polygon.locations[0]);
|
|
310
|
-
}}
|
|
311
|
-
/>
|
|
312
|
-
</>
|
|
313
|
-
);
|
|
314
|
-
};
|
|
315
|
-
```
|
|
316
|
-
|
|
317
|
-
### Get Directions
|
|
318
|
-
|
|
319
|
-
This API can be used to get a directions object from any MappedinLocation | MappedinNode | MappedinPolygon to any MappedinLocation | MappedinNode | MappedinPolygon. This can be used to show Text directions, as well as draw paths.
|
|
320
|
-
|
|
321
|
-
Example:
|
|
322
|
-
|
|
323
|
-
```tsx
|
|
324
|
-
...
|
|
325
|
-
<Button
|
|
326
|
-
title="Get Directions"
|
|
327
|
-
onPress={async () => {
|
|
328
|
-
try {
|
|
329
|
-
const directions = selectedLocation.directionsTo(destinationLocation);
|
|
330
|
-
console.log(directions);
|
|
331
|
-
} catch (e) {
|
|
332
|
-
console.error(e);
|
|
333
|
-
}
|
|
334
|
-
}}
|
|
335
|
-
></Button>
|
|
336
|
-
...
|
|
337
|
-
|
|
338
|
-
```
|
|
339
|
-
|
|
340
|
-
## Get directions from one location to another and show path and connections on map
|
|
341
|
-
|
|
342
|
-
```tsx
|
|
343
|
-
import { MiMapView } from '@mappedin/react-native-sdk';
|
|
344
|
-
import type {
|
|
345
|
-
MappedinLocation,
|
|
346
|
-
MapViewStore,
|
|
347
|
-
MappedinPolygon,
|
|
348
|
-
} from '@mappedin/react-native-sdk';
|
|
349
|
-
|
|
350
|
-
const App = () => {
|
|
351
|
-
const mapView = React.useRef<MapViewStore>(null);
|
|
352
|
-
const [destination, setDestination] = React.useState<MappedinLocation>(null);
|
|
353
|
-
const [departure, setDeparture] = React.useState<MappedinLocation>(null);
|
|
354
|
-
|
|
355
|
-
return (
|
|
356
|
-
<>
|
|
357
|
-
<MiMapView
|
|
358
|
-
style={{flex: 1}}
|
|
359
|
-
ref={mapView}
|
|
360
|
-
options={options}
|
|
361
|
-
onPolygonClicked={({polygon: MappedinPolygon}) => {
|
|
362
|
-
// first, let's set departure
|
|
363
|
-
if (departure == null) {
|
|
364
|
-
setDeparture(polygon.locations[0]);
|
|
365
|
-
} else {
|
|
366
|
-
// then, destination
|
|
367
|
-
setDestination(polygon.locations[0]);
|
|
368
|
-
}
|
|
369
|
-
}}
|
|
370
|
-
/>
|
|
371
|
-
<Button
|
|
372
|
-
title="Get Directions"
|
|
373
|
-
onPress={async () => {
|
|
374
|
-
try {
|
|
375
|
-
// get Directions
|
|
376
|
-
const directions = departure.directionsTo(destination);
|
|
377
|
-
// draw path on map
|
|
378
|
-
await mapView.current?.Journey.draw(directions);
|
|
379
|
-
// focus on the path
|
|
380
|
-
mapView.current?.Camera.focusOn({
|
|
381
|
-
targets: {
|
|
382
|
-
nodes: directions.path,
|
|
383
|
-
},
|
|
384
|
-
});
|
|
385
|
-
} catch (e) {
|
|
386
|
-
console.error(e);
|
|
387
|
-
}
|
|
388
|
-
}}></Button>
|
|
389
|
-
<Button
|
|
390
|
-
title="Reset"
|
|
391
|
-
onPress={() => {
|
|
392
|
-
mapView.current?.removeAllPaths();
|
|
393
|
-
setDeparture(undefined);
|
|
394
|
-
setDestination(undefined);
|
|
395
|
-
}}></Button>
|
|
396
|
-
</>
|
|
397
|
-
);
|
|
398
|
-
};
|
|
399
|
-
```
|
|
400
|
-
|
|
93
|
+
> See more detailed samples and guides on the [Mappedin Developer Portal](https://developer.mappedin.com)
|
|
401
94
|
## Preparing SVGs for use as assets in markers/tooltips/etc
|
|
402
95
|
|
|
403
96
|
SVG is a popular format for image assets, which means there are a lot of proprietary, broken, or unnecessary tags when getting SVGs online.
|
|
@@ -421,122 +114,6 @@ Once the SVGs are prepared, they need to be wrapped in a `div` element which wil
|
|
|
421
114
|
`
|
|
422
115
|
```
|
|
423
116
|
|
|
424
|
-
## Adding a Coordinate by lat/lon
|
|
425
|
-
|
|
426
|
-
```tsx
|
|
427
|
-
import { MiMapView } from '@mappedin/react-native-sdk';
|
|
428
|
-
import type {
|
|
429
|
-
MapViewStore,
|
|
430
|
-
} from '@mappedin/react-native-sdk';
|
|
431
|
-
|
|
432
|
-
// Imperative API
|
|
433
|
-
const mapView = React.useRef<MapViewStore>();
|
|
434
|
-
|
|
435
|
-
const App = () => {
|
|
436
|
-
return (
|
|
437
|
-
<>
|
|
438
|
-
<MiMapView
|
|
439
|
-
style={{ flex: 1 }}
|
|
440
|
-
ref={mapView}
|
|
441
|
-
options={options}
|
|
442
|
-
onFirstMapLoaded={() => {
|
|
443
|
-
// create a coordinate
|
|
444
|
-
const coordinate = mapView.current.venueData.maps[1].createCoordinate(43.52117572969203, -80.53869317220372);
|
|
445
|
-
|
|
446
|
-
const coordinate2 = mapView.current.venueData.maps[1].createCoordinate(44.52117572969203, -79.53869317220372);
|
|
447
|
-
// find distance between coordinates:
|
|
448
|
-
console.log(coordinate.absoluteDistanceTo(coordinate2));
|
|
449
|
-
|
|
450
|
-
// coordinates can also be used to place markers:
|
|
451
|
-
mapView.current.createMarker(coordinate, ...)
|
|
452
|
-
}}
|
|
453
|
-
/>
|
|
454
|
-
)
|
|
455
|
-
}
|
|
456
|
-
```
|
|
457
|
-
|
|
458
|
-
## Customizing appearance of labels
|
|
459
|
-
|
|
460
|
-
Labels are added on map load by default, but this can be overriden by setting <a href="modules.html#tshowvenueoptions">labelAllLocationsOnInit</a> to false and taking control of labeling. We provide <a href="modules.html#labelthemes">2 themes</a>, and <a href="modules.html#tlabelappearance">full control</a> over further customization.
|
|
461
|
-
|
|
462
|
-
```tsx
|
|
463
|
-
import { MiMapView, labelThemes } from '@mappedin/react-native-sdk';
|
|
464
|
-
import type {
|
|
465
|
-
MapViewStore,
|
|
466
|
-
} from '@mappedin/react-native-sdk';
|
|
467
|
-
|
|
468
|
-
// Imperative API
|
|
469
|
-
const mapView = React.useRef<MapViewStore>();
|
|
470
|
-
|
|
471
|
-
const App = () => {
|
|
472
|
-
return (
|
|
473
|
-
<>
|
|
474
|
-
<MiMapView
|
|
475
|
-
style={{ flex: 1 }}
|
|
476
|
-
ref={mapView}
|
|
477
|
-
options={{ ...options, labelAllLocationsOnInit: false }}
|
|
478
|
-
onFirstMapLoaded={() => {
|
|
479
|
-
// use one of the themes
|
|
480
|
-
mapView.current.labelAllLocations({ appearance: labelThemes.lightOnDark })
|
|
481
|
-
// OR, customize a set of properties
|
|
482
|
-
mapView.current.labelAllLocations({ appearance: { text: { size: 12 }} })
|
|
483
|
-
// OR, do both
|
|
484
|
-
mapView.current.labelAllLocations({ appearance:
|
|
485
|
-
{
|
|
486
|
-
...labelThemes.lightOnDark,
|
|
487
|
-
margin: 20,
|
|
488
|
-
text: {
|
|
489
|
-
...labelThemes.lightOnDark.text,
|
|
490
|
-
size: 20
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
})
|
|
494
|
-
}}
|
|
495
|
-
/>
|
|
496
|
-
)
|
|
497
|
-
}
|
|
498
|
-
```
|
|
499
|
-
|
|
500
|
-
## Adding/Removing markers
|
|
501
|
-
|
|
502
|
-
```tsx
|
|
503
|
-
import { MiMapView } from '@mappedin/react-native-sdk';
|
|
504
|
-
import type {
|
|
505
|
-
MapViewStore,
|
|
506
|
-
} from '@mappedin/react-native-sdk';
|
|
507
|
-
|
|
508
|
-
// Imperative API
|
|
509
|
-
const mapView = React.useRef<MapViewStore>();
|
|
510
|
-
const markerId = React.useRef(null);
|
|
511
|
-
|
|
512
|
-
const App = () => {
|
|
513
|
-
return (
|
|
514
|
-
<>
|
|
515
|
-
<MiMapView
|
|
516
|
-
style={{ flex: 1 }}
|
|
517
|
-
ref={mapView}
|
|
518
|
-
options={options}
|
|
519
|
-
onDataLoaded={() => {
|
|
520
|
-
mapView.current.BlueDot.enable();
|
|
521
|
-
}}
|
|
522
|
-
onPolygonClicked={({ polygon }) => {
|
|
523
|
-
if (markerId != null) {
|
|
524
|
-
mapView.current.removeMarker(markerId);
|
|
525
|
-
}
|
|
526
|
-
// Let's add a marker anchored to the top of the first entrance to polygon
|
|
527
|
-
markerId.current = mapView.current.createMarker(polygon.entrances[0], `
|
|
528
|
-
<div style="width: 32px; height: 32px;">
|
|
529
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 293.334 293.334"><g fill="#010002"><path d="M146.667 0C94.903 0 52.946 41.957 52.946 93.721c0 22.322 7.849 42.789 20.891 58.878 4.204 5.178 11.237 13.331 14.903 18.906 21.109 32.069 48.19 78.643 56.082 116.864 1.354 6.527 2.986 6.641 4.743.212 5.629-20.609 20.228-65.639 50.377-112.757 3.595-5.619 10.884-13.483 15.409-18.379a94.561 94.561 0 0016.154-24.084c5.651-12.086 8.882-25.466 8.882-39.629C240.387 41.962 198.43 0 146.667 0zm0 144.358c-28.892 0-52.313-23.421-52.313-52.313 0-28.887 23.421-52.307 52.313-52.307s52.313 23.421 52.313 52.307c0 28.893-23.421 52.313-52.313 52.313z"/><circle cx="146.667" cy="90.196" r="21.756"/></g></svg>
|
|
530
|
-
</div>
|
|
531
|
-
`,
|
|
532
|
-
{
|
|
533
|
-
anchor: MARKER_ANCHOR.TOP,
|
|
534
|
-
})
|
|
535
|
-
}}
|
|
536
|
-
/>
|
|
537
|
-
)
|
|
538
|
-
}
|
|
539
|
-
```
|
|
540
117
|
|
|
541
118
|
## Get nearest node to point on screen
|
|
542
119
|
|
|
@@ -565,64 +142,6 @@ const App = () => {
|
|
|
565
142
|
};
|
|
566
143
|
```
|
|
567
144
|
|
|
568
|
-
## Get Directions from BlueDot and show path and connections on map
|
|
569
|
-
|
|
570
|
-
```tsx
|
|
571
|
-
import { MiMapView } from '@mappedin/react-native-sdk';
|
|
572
|
-
import type {
|
|
573
|
-
TBlueDotUpdate,
|
|
574
|
-
MapViewStore,
|
|
575
|
-
MappedinLocation,
|
|
576
|
-
MappedinNode,
|
|
577
|
-
} from '@mappedin/react-native-sdk';
|
|
578
|
-
|
|
579
|
-
// Imperative API
|
|
580
|
-
const mapView = React.useRef<MapViewStore>();
|
|
581
|
-
const nearestNode = React.useRef<MappedinNode>();
|
|
582
|
-
const [
|
|
583
|
-
selectedLocation,
|
|
584
|
-
setSelectedLocation,
|
|
585
|
-
] = React.useState<MappedinLocation>({});
|
|
586
|
-
|
|
587
|
-
const App = () => {
|
|
588
|
-
return (
|
|
589
|
-
<>
|
|
590
|
-
<MiMapView
|
|
591
|
-
style={{ flex: 1 }}
|
|
592
|
-
ref={mapView}
|
|
593
|
-
options={options}
|
|
594
|
-
onDataLoaded={() => {
|
|
595
|
-
mapView.current.BlueDot.enable();
|
|
596
|
-
}}
|
|
597
|
-
onBlueDotStateChanged={({ stateChange }) => {
|
|
598
|
-
nearestNode.current = stateChange.nearestNode;
|
|
599
|
-
}}
|
|
600
|
-
onPolygonClicked={({ polygon: MappedinPolygon }) => {
|
|
601
|
-
setSelectedLocation(polygon.locations[0]);
|
|
602
|
-
}}
|
|
603
|
-
/>
|
|
604
|
-
<Button
|
|
605
|
-
title="Get Directions"
|
|
606
|
-
onPress={async () => {
|
|
607
|
-
try {
|
|
608
|
-
// get Directions
|
|
609
|
-
const directions = nearestNode.current.directionsTo(selectedLocation);
|
|
610
|
-
// draw path and connections on map
|
|
611
|
-
await controller.current?.Journey.draw(directions);
|
|
612
|
-
// focus on the path
|
|
613
|
-
controller.current?.Camera.focusOn({ targets: {
|
|
614
|
-
nodes: directions.path,
|
|
615
|
-
}
|
|
616
|
-
});
|
|
617
|
-
} catch (e) {
|
|
618
|
-
console.error(e);
|
|
619
|
-
}
|
|
620
|
-
}}
|
|
621
|
-
></Button>
|
|
622
|
-
</>
|
|
623
|
-
);
|
|
624
|
-
};
|
|
625
|
-
```
|
|
626
145
|
|
|
627
146
|
## Search and Suggestions
|
|
628
147
|
|
|
@@ -677,96 +196,6 @@ const App = () => {
|
|
|
677
196
|
};
|
|
678
197
|
```
|
|
679
198
|
|
|
680
|
-
## Use `react-native-location` to power BlueDot
|
|
681
|
-
|
|
682
|
-
```tsx
|
|
683
|
-
import RNLocation from 'react-native-location';
|
|
684
|
-
|
|
685
|
-
const App = () => {
|
|
686
|
-
...
|
|
687
|
-
|
|
688
|
-
RNLocation.requestPermission({
|
|
689
|
-
ios: 'whenInUse',
|
|
690
|
-
android: {
|
|
691
|
-
detail: 'coarse',
|
|
692
|
-
},
|
|
693
|
-
}).then((granted) => {
|
|
694
|
-
if (granted) {
|
|
695
|
-
// Enable blue dot
|
|
696
|
-
mapView.current.BlueDot.enable();
|
|
697
|
-
RNLocation.subscribeToLocationUpdates((locations) => {
|
|
698
|
-
const {
|
|
699
|
-
accuracy,
|
|
700
|
-
floor,
|
|
701
|
-
latitude,
|
|
702
|
-
longitude,
|
|
703
|
-
timestamp,
|
|
704
|
-
} = locations[0];
|
|
705
|
-
|
|
706
|
-
const location = {
|
|
707
|
-
timestamp,
|
|
708
|
-
coords: {
|
|
709
|
-
latitude,
|
|
710
|
-
longitude,
|
|
711
|
-
accuracy,
|
|
712
|
-
floorLevel: floor,
|
|
713
|
-
},
|
|
714
|
-
};
|
|
715
|
-
// pass locations in
|
|
716
|
-
mapView.current.overrideLocation(location);
|
|
717
|
-
});
|
|
718
|
-
}
|
|
719
|
-
});
|
|
720
|
-
|
|
721
|
-
...
|
|
722
|
-
};
|
|
723
|
-
```
|
|
724
|
-
|
|
725
|
-
## MiniMap
|
|
726
|
-
|
|
727
|
-
Component Signature:
|
|
728
|
-
|
|
729
|
-
```typescript
|
|
730
|
-
const MiMiniMap = (props: TMiniMapProps) => React.ReactElement;
|
|
731
|
-
```
|
|
732
|
-
|
|
733
|
-
### Props:
|
|
734
|
-
|
|
735
|
-
<a href="modules.html#tmiminimapprops">Documented in Detail here</a>
|
|
736
|
-
|
|
737
|
-
| Prop | Description | Signature | Required |
|
|
738
|
-
| --------------------- | ---------------------------------------------- | ------------------------------------------------------------------------ | -------- |
|
|
739
|
-
| options | Options to initialize MapView with | <a href="modules.html#tmimapviewoptions">`TMiMapViewOptions`<a> | Yes |
|
|
740
|
-
| location | Options to initialize MapView with | <a href="mclasses/mappedinlocation.html">`MappedinLocation \| string`<a> | Yes |
|
|
741
|
-
| onLoad | Gets called when minimap is rendered | () => void | No |
|
|
742
|
-
| polygonHighlightColor | Color to use when highlighting polygon | `string` | No |
|
|
743
|
-
| focusOptions | Override focus Options when generating minimap | <a href="modules.html#tfocusoptions">`TFocusOptions`</a> | No |
|
|
744
|
-
|
|
745
|
-
Example:
|
|
746
|
-
|
|
747
|
-
```tsx
|
|
748
|
-
const App = () => {
|
|
749
|
-
return (
|
|
750
|
-
<MiMiniMap
|
|
751
|
-
style={{ width: 500, height: 200 }}
|
|
752
|
-
options={options: TGetVenueOptions}
|
|
753
|
-
/**
|
|
754
|
-
* Called when miniMap is rendered
|
|
755
|
-
*/
|
|
756
|
-
onLoad={() => {}}
|
|
757
|
-
/**
|
|
758
|
-
* What color to use when highlighting polygon
|
|
759
|
-
*/
|
|
760
|
-
polygonHighlightColor={string}
|
|
761
|
-
/**
|
|
762
|
-
* Finer control over focus
|
|
763
|
-
*/
|
|
764
|
-
focusOptions={options: TFocusOptions}
|
|
765
|
-
location={selectedLocation: MappedinLocation | MappedinLocation["id"]}
|
|
766
|
-
/>
|
|
767
|
-
);
|
|
768
|
-
};
|
|
769
|
-
```
|
|
770
199
|
|
|
771
200
|
### [experimental] Fetching an offline Venue bundle
|
|
772
201
|
|