@mappedin/react-native-sdk 5.0.0-beta.7 → 5.0.0-beta.9

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 (4) hide show
  1. package/README.md +22 -31
  2. package/dist/index.d.ts +690 -1224
  3. package/dist/index.js +279 -279
  4. package/package.json +2 -2
package/README.md CHANGED
@@ -43,6 +43,7 @@ const MiMapView = (props: TMapViewProps) => React.ReactElement;
43
43
  | onFirstMapLoaded | Fires when map can first be interacted with | () => void | No |
44
44
  | onBlueDotStateChanged | Fires when BlueDot state changes | ({ stateChange: <a href="modules.html#tbluedotstatechange">`TBlueDotStateChange`</a> }) => void | No |
45
45
  | onBlueDotPositionUpdated | Fires when BlueDot position changes | ({ update: <a href="modules.html#tbluedotpositionupdate">`TBlueDotPositionUpdate`</a> }) => void | No |
46
+ | onCameraChanged | Fires when Camera position, tilt, zoom or rotation changes | ({ change: <a href="modules.html#TCameraChange">`TCameraChange`</a> }) => void | No |
46
47
  | onStateChanged | Fires when SDK State changes | ({ state: <a href="enums/state.html">`STATE`</a> }) => void | No |
47
48
 
48
49
  ### Imperative API
@@ -172,7 +173,7 @@ const App = () => {
172
173
  ref={mapView}
173
174
  options={options}
174
175
  onFirstMapLoaded={() => {
175
- mapView.current!.Camera.set({ positionOptions: { rotation: 90 });
176
+ mapView.current!.Camera.set({ rotation: 90 });
176
177
  }}
177
178
  />
178
179
  );
@@ -212,10 +213,9 @@ const App = () => {
212
213
  mapView.current.clearAllPolygonColors();
213
214
  mapView.current.setPolygonColor(polygon, 'red');
214
215
  // lets wait for the focusOn to complete
215
- await mapView.current.Camera.focusOn({ targets: {
216
- polygons: [polygon],
217
- }
218
- });
216
+ await mapView.current.Camera.focusOn({
217
+ polygons: [polygon]
218
+ });
219
219
  console.log('success!');
220
220
  }}
221
221
  />
@@ -336,33 +336,28 @@ Example:
336
336
 
337
337
  ```
338
338
 
339
- ## Get Directions from One Location to Another and show path and connections on map
339
+ ## Get directions from one location to another and show path and connections on map
340
340
 
341
341
  ```tsx
342
342
  import { MiMapView } from '@mappedin/react-native-sdk';
343
343
  import type {
344
- TBlueDotUpdate,
345
- MapViewStore,
346
344
  MappedinLocation,
347
- MappedinNode,
345
+ MapViewStore,
346
+ MappedinPolygon,
348
347
  } from '@mappedin/react-native-sdk';
349
348
 
350
- // Imperative API
351
- const mapView = React.useRef<MapViewStore>();
352
- const [destination, setDestination] = React.useRef<MappedinLocation>();
353
- const [departure, setDeparture] = React.useState<MappedinLocation>({});
354
-
355
349
  const App = () => {
350
+ const mapView = React.useRef<MapViewStore>(null);
351
+ const [destination, setDestination] = React.useState<MappedinLocation>(null);
352
+ const [departure, setDeparture] = React.useState<MappedinLocation>(null);
353
+
356
354
  return (
357
355
  <>
358
356
  <MiMapView
359
- style={{ flex: 1 }}
357
+ style={{flex: 1}}
360
358
  ref={mapView}
361
359
  options={options}
362
- onDataLoaded={() => {
363
- mapView.current.BlueDot.enable();
364
- }}
365
- onPolygonClicked={({ polygon: MappedinPolygon }) => {
360
+ onPolygonClicked={({polygon: MappedinPolygon}) => {
366
361
  // first, let's set departure
367
362
  if (departure == null) {
368
363
  setDeparture(polygon.locations[0]);
@@ -379,25 +374,22 @@ const App = () => {
379
374
  // get Directions
380
375
  const directions = departure.directionsTo(destination);
381
376
  // draw path on map
382
- await controller.current?.Journey.draw(directions);
377
+ await mapView.current?.Journey.draw(directions);
383
378
  // focus on the path
384
- controller.current?.Camera.focusOn({ targets: {
385
- nodes: directions.path,
386
- }
379
+ mapView.current?.Camera.focusOn({
380
+ nodes: directions.path
387
381
  });
388
382
  } catch (e) {
389
383
  console.error(e);
390
384
  }
391
- }}
392
- ></Button>
385
+ }}></Button>
393
386
  <Button
394
387
  title="Reset"
395
388
  onPress={() => {
396
- mapView.current.clearAllPaths();
389
+ mapView.current?.removeAllPaths();
397
390
  setDeparture(undefined);
398
391
  setDestination(undefined);
399
- }}
400
- ></Button>
392
+ }}></Button>
401
393
  </>
402
394
  );
403
395
  };
@@ -615,9 +607,8 @@ const App = () => {
615
607
  // draw path and connections on map
616
608
  await controller.current?.Journey.draw(directions);
617
609
  // focus on the path
618
- controller.current?.Camera.focusOn({ targets: {
619
- nodes: directions.path,
620
- }
610
+ controller.current?.Camera.focusOn({
611
+ nodes: directions.path
621
612
  });
622
613
  } catch (e) {
623
614
  console.error(e);