Trying to get the BlueDot to work within a React native app (have gotten it to work on React Web, without any issues). Below is the simple implementation, based on documentation and one of the predefined map. Attached is the error I get. Any help is much appreciated, feeling stuck. I have installed @mappedin**/blue-dot.**
import React, { useEffect, useCallback } from ‘react’;
import { View, Text, TouchableOpacity } from ‘react-native’;
import { MapView, useMap } from ‘@mappedin/react-native-sdk’;
import { useBlueDot, useBlueDotEvent } from ‘@mappedin/blue-dot/rn’;
export default function App() {
return (
<MapView mapData={{
key: “mik_yeBk0Vf0nNJtpesfu560e07e5”,
secret: “mis_2g9ST8ZcSFb5R9fPnsvYhrX3RyRwPtDGbMGweCYKEq385431022”,
mapId: “64ef49e662fd90fe020bee61”,
}}>
);
}
function BlueDotDisplay() {
// All methods are async and return Promises
const {
isReady,
isEnabled,
state,
position,
floor,
following,
accuracy,
heading,
enable,
disable,
update,
follow,
unfollow
} = useBlueDot();
// Listen for position updates
useBlueDotEvent(‘position-update’, useCallback((event) => {
console.log(‘Position updated:’, event.coordinate, event.floor);
}, ));
// Listen for state changes
useBlueDotEvent(‘state-change’, useCallback((event) => {
console.log(‘State changed:’, event.state);
}, ));
// Listen for follow mode changes
useBlueDotEvent(‘follow-change’, useCallback((event) => {
console.log(‘Follow mode:’, event.following);
}, ));
useEffect(() => {
if (isReady && !isEnabled) {
// All methods are async - use await or .then()
enable({
radius: 15,
color: ‘#ff0000’,
watchDevicePosition: false
});
}
}, [isReady, isEnabled, enable]);
const handleUpdatePosition = useCallback(async () => {
try {
// Update position manually
await update({
latitude: 43.6532,
longitude: -79.3832,
accuracy: 5,
heading: 90,
floorOrFloorId: floor
});
// Enable follow mode
await follow('position-and-heading', {
zoomLevel: 19
});
} catch (error) {
console.error('Failed to update position:', error);
}
}, [update, follow, floor]);
return (
Is Ready: {isReady ? ‘Yes’ : ‘No’}
Is Enabled: {isEnabled ? ‘Yes’ : ‘No’}
State: {state}
Following: {following ? ‘Yes’ : ‘No’}
{position && (
Position: {position.latitude.toFixed(4)}, {position.longitude.toFixed(4)}
)}
{accuracy && Accuracy: {accuracy.toFixed(1)}m}
{heading && Heading: {heading.toFixed(0)}}
Update Position & Follow
);
}
