@mappedin/react-native-sdk 5.0.0-beta.7 → 5.0.0-beta.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.
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
@@ -336,33 +337,28 @@ Example:
336
337
 
337
338
  ```
338
339
 
339
- ## Get Directions from One Location to Another and show path and connections on map
340
+ ## Get directions from one location to another and show path and connections on map
340
341
 
341
342
  ```tsx
342
343
  import { MiMapView } from '@mappedin/react-native-sdk';
343
344
  import type {
344
- TBlueDotUpdate,
345
- MapViewStore,
346
345
  MappedinLocation,
347
- MappedinNode,
346
+ MapViewStore,
347
+ MappedinPolygon,
348
348
  } from '@mappedin/react-native-sdk';
349
349
 
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
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
+
356
355
  return (
357
356
  <>
358
357
  <MiMapView
359
- style={{ flex: 1 }}
358
+ style={{flex: 1}}
360
359
  ref={mapView}
361
360
  options={options}
362
- onDataLoaded={() => {
363
- mapView.current.BlueDot.enable();
364
- }}
365
- onPolygonClicked={({ polygon: MappedinPolygon }) => {
361
+ onPolygonClicked={({polygon: MappedinPolygon}) => {
366
362
  // first, let's set departure
367
363
  if (departure == null) {
368
364
  setDeparture(polygon.locations[0]);
@@ -379,25 +375,24 @@ const App = () => {
379
375
  // get Directions
380
376
  const directions = departure.directionsTo(destination);
381
377
  // draw path on map
382
- await controller.current?.Journey.draw(directions);
378
+ await mapView.current?.Journey.draw(directions);
383
379
  // focus on the path
384
- controller.current?.Camera.focusOn({ targets: {
380
+ mapView.current?.Camera.focusOn({
381
+ targets: {
385
382
  nodes: directions.path,
386
- }
383
+ },
387
384
  });
388
385
  } catch (e) {
389
386
  console.error(e);
390
387
  }
391
- }}
392
- ></Button>
388
+ }}></Button>
393
389
  <Button
394
390
  title="Reset"
395
391
  onPress={() => {
396
- mapView.current.clearAllPaths();
392
+ mapView.current?.removeAllPaths();
397
393
  setDeparture(undefined);
398
394
  setDestination(undefined);
399
- }}
400
- ></Button>
395
+ }}></Button>
401
396
  </>
402
397
  );
403
398
  };