## version-5.0 ### API Reference # API Reference ## Latest Version Mappedin SDK for React Native v5.41.10 ## Previous Versions v5.41.9v5.41.8v5.41.7v5.41.5v5.41.4v5.41.3v5.41.2v5.40.2v5.40.1v5.40.0v5.39.3v5.39.2v5.39.1v5.39.0v5.38.0v5.37.0v5.36.0v5.35.0v5.34.3v5.34.1v5.34.0v5.33.0v5.32.0v5.31.2v5.31.1v5.31.0v5.30.5v5.30.4v5.30.3v5.30.2v5.30.0v5.28.0v5.27.1v5.27.0v5.26.0v5.25.0v5.24.1v5.24.0v5.23.0v5.22.0v5.21.0v5.20.0v5.19.0v5.18.0v5.17.0v5.16.0v5.15.2v5.15.1v5.15.0v5.14.1v5.14.0v5.13.0v5.12.1v5.12.0v5.11.0v5.10.2v5.10.1v5.10.0v5.9.1v5.9.0v5.8.0v5.7.1v5.7.0v5.6.1v5.6.0v5.5.0v5.4.0v5.3.0v5.2.2v5.2.1v5.2.0v5.1.5v5.1.4v5.1.3v5.1.2v5.1.1v5.1.0v5.0.3v5.0.2v5.0.1v5.0.0v5.0.0-beta.11v5.0.0-beta.10v5.0.0-beta.9v5.0.0-beta.8v5.0.0-beta.7v5.0.0-beta.5v5.0.0-beta.4 ### Blue Dot # Blue Dot > Displaying user position inside a building is not accurate with just GPS. However, there are a multitude of Indoor Positioning Systems (IPS) utilizing different technological approaches to providing an accurate and reliable positioning inside. Mappedin works with any IPS capable of providing the SDK with latitude, longitude and floor level information. ## Display the Blue Dot To display a Blue Dot with the SDK, you'll need the position information. The following is a point in the fictional Mappedin Demo Mall. You can create positions and paths for your venue using the Blue Dot Data Faker tool. Below is an example of the geolocation object: ```ts const location = { timestamp: 1583957906820, coords: { accuracy: 5, latitude: 43.52012478635707, longitude: -80.53951744629536, floorLevel: 0, }, type: 0, }; ``` Inside the `onFirstMapLoaded` callback enable Blue Dot with default settings and then give it the position object to display it on the map. ```tsx mapView.current?.BlueDot.enable(); mapView.current?.overrideLocation(location); ``` This is a full sample for overriding Blue Dot location with a given position and displaying it on the map: ```tsx import React from 'react'; import { MapViewStore, MiMapView } from '@mappedin/react-native-sdk'; // See Trial API key Terms and Conditions // https://developer.mappedin.com/docs/demo-keys-and-maps const options = { clientId: '5eab30aa91b055001a68e996', clientSecret: 'RJyRXKcryCMy4erZqqCbuB1NbR66QTGNXVE0x3Pg6oCIlUR1', venue: 'mappedin-demo-mall', labelAllLocationsOnInit: false, }; const App = () => { const mapView = React.useRef(null); const location = { timestamp: 1583957906820, coords: { accuracy: 5, latitude: 43.52012478635707, longitude: -80.53951744629536, floorLevel: 0, }, type: 0, }; return ( { mapView.current?.BlueDot.enable(); mapView.current?.overrideLocation(location); }} /> ); }; export default App; ``` ## Blue Dot Display States - When the Blue Dot position given to the Mappedin SDK has a high accuracy (within a few meters) and is on the floor currently displayed, it is displayed as bright blue. !Blue Dot - Accurate - If the Mappedin Blue Dot is able to detect that a given position update is inaccurate, a semi-transparent blue shadow is displayed underneath the Blue Dot to indicate uncertainty range. !Bluedot Inaccurate - When the BlueDot is on another floor it will look semi-transparent. !Blue Dot - Accurate on another floor - The uncertainty range is shown also when displaying the Blue Dot on another floor than the currently viewed one. !Blue Dot Inaccurate on another floor - 30 seconds after the latest position update, the BlueDot is displayed as greyed out as it's possible that the user has moved but no updates have been received. !Blue Dot - Outdated ## Follow mode To keep the camera following the Blue Dot (unless user moves the view), you can set the SDK to `FOLLOW` mode. ```tsx mapView.current?.setState(STATE.FOLLOW); ``` ## Get live position with react-native-location `react-native-location` is one of the many packages providing positioning service access. The sample code below shows the quickest way to integrate that with the Mappedin SDK for React Native. The code is edited for brevity to only display the relevant bits. ```tsx import RNLocation from 'react-native-location'; const App = () => { RNLocation.requestPermission({ ios: 'whenInUse', android: { detail: 'coarse', }, }).then((granted) => { if (granted) { // Enable blue dot mapView.current.BlueDot.enable(); RNLocation.subscribeToLocationUpdates((locations) => { const { accuracy, floor, latitude, longitude, timestamp } = locations[0]; const location = { timestamp, coords: { latitude, longitude, accuracy, floorLevel: floor, }, }; // pass locations in mapView.current.overrideLocation(location); }); } }); }; ``` ## Directions from Blue Dot to a location The following is a full sample for displaying wayfinding directions from the user's current position to a selected location. ```tsx import React from 'react'; import { MappedinLocation, MappedinNode, MapViewStore, MiMapView } from '@mappedin/react-native-sdk'; import { Button } from 'react-native'; // See Trial API key Terms and Conditions // https://developer.mappedin.com/docs/demo-keys-and-maps const options = { clientId: '5eab30aa91b055001a68e996', clientSecret: 'RJyRXKcryCMy4erZqqCbuB1NbR66QTGNXVE0x3Pg6oCIlUR1', venue: 'mappedin-demo-mall', labelAllLocationsOnInit: false, }; const App = () => { const mapView = React.useRef(null); const nearestNode = React.useRef(); const [selectedLocation, setSelectedLocation] = React.useState({}); const location = { timestamp: 1583957906820, coords: { accuracy: 5, latitude: 43.52012478635707, longitude: -80.53951744629536, floorLevel: 0, }, type: 0, }; return ( <> { mapView.current?.BlueDot.enable(); mapView.current?.overrideLocation(location); }} onBlueDotPositionUpdated={({ update }) => { nearestNode.current = update.nearestNode; }} onPolygonClicked={({ polygon }) => { setSelectedLocation(polygon.locations[0]); mapView.current?.setPolygonColor(polygon, '#ff0000'); }} />