@mappedin/blue-dot 6.0.1-beta.56 → 6.0.1-beta.58
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 +124 -0
- package/lib/blue-dot.iife.js.map +4 -4
- package/lib/esm/chunk-TPJ6NPMJ.js +1560 -0
- package/lib/esm/chunk-TPJ6NPMJ.js.map +7 -0
- package/lib/esm/index.d.ts +221 -78
- package/lib/esm/index.js +6 -229
- package/lib/esm/index.js.map +3 -3
- package/lib/esm/react/index.d.ts +877 -0
- package/lib/esm/react/index.js +75 -0
- package/lib/esm/react/index.js.map +7 -0
- package/lib/rn/blue-dot.d.ts +188 -0
- package/lib/rn/constants.d.ts +11 -0
- package/lib/rn/index-rn.js +65 -24
- package/lib/rn/index-rn.js.map +3 -3
- package/lib/rn/model-manager.d.ts +24 -0
- package/lib/rn/rn/use-blue-dot.d.ts +11 -95
- package/lib/rn/schemas.d.ts +22 -0
- package/lib/rn/state-machine.d.ts +2 -0
- package/lib/rn/types.d.ts +80 -21
- package/lib/rn/utils.d.ts +75 -0
- package/package.json +33 -22
package/README.md
CHANGED
|
@@ -46,6 +46,9 @@ blueDot.update({
|
|
|
46
46
|
// Optional floor or floor ID
|
|
47
47
|
floorOrFloorId,
|
|
48
48
|
})
|
|
49
|
+
|
|
50
|
+
// Attach the camera to the BlueDot
|
|
51
|
+
blueDot.follow('position-only');
|
|
49
52
|
```
|
|
50
53
|
|
|
51
54
|
### Options
|
|
@@ -115,3 +118,124 @@ export type BlueDotOptions = {
|
|
|
115
118
|
debug?: boolean;
|
|
116
119
|
};
|
|
117
120
|
```
|
|
121
|
+
|
|
122
|
+
### React Native
|
|
123
|
+
|
|
124
|
+
```tsx
|
|
125
|
+
import React, { useEffect, useCallback } from 'react';
|
|
126
|
+
import { View, Text, TouchableOpacity } from 'react-native';
|
|
127
|
+
import { MapView, useMapData } from '@mappedin/react-native-sdk';
|
|
128
|
+
import { useBlueDot, useBlueDotEvent } from '@mappedin/blue-dot/rn';
|
|
129
|
+
|
|
130
|
+
function MyComponent() {
|
|
131
|
+
const { mapData } = useMapData({
|
|
132
|
+
key: 'your-api-key',
|
|
133
|
+
secret: 'your-api-secret',
|
|
134
|
+
mapId: 'your-map-id',
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
return (
|
|
138
|
+
<MapView mapData={mapData}>
|
|
139
|
+
<BlueDotDisplay />
|
|
140
|
+
</MapView>
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function BlueDotDisplay() {
|
|
145
|
+
// All methods are async and return Promises
|
|
146
|
+
const {
|
|
147
|
+
isReady,
|
|
148
|
+
isEnabled,
|
|
149
|
+
state,
|
|
150
|
+
position,
|
|
151
|
+
floor,
|
|
152
|
+
isFollowing,
|
|
153
|
+
accuracy,
|
|
154
|
+
heading,
|
|
155
|
+
enable,
|
|
156
|
+
disable,
|
|
157
|
+
update,
|
|
158
|
+
follow,
|
|
159
|
+
} = useBlueDot();
|
|
160
|
+
|
|
161
|
+
// Listen for position updates
|
|
162
|
+
useBlueDotEvent(
|
|
163
|
+
'position-update',
|
|
164
|
+
useCallback(event => {
|
|
165
|
+
console.log('Position updated:', event.coordinate, event.floor);
|
|
166
|
+
}, []),
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
// Listen for state changes
|
|
170
|
+
useBlueDotEvent(
|
|
171
|
+
'state-change',
|
|
172
|
+
useCallback(event => {
|
|
173
|
+
console.log('State changed:', event.state);
|
|
174
|
+
}, []),
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
// Listen for follow mode changes
|
|
178
|
+
useBlueDotEvent(
|
|
179
|
+
'follow-change',
|
|
180
|
+
useCallback(event => {
|
|
181
|
+
console.log('Follow mode:', event.following);
|
|
182
|
+
}, []),
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
useEffect(() => {
|
|
186
|
+
if (isReady && !isEnabled) {
|
|
187
|
+
// All methods are async - use await or .then()
|
|
188
|
+
enable({
|
|
189
|
+
radius: 15,
|
|
190
|
+
color: '#ff0000',
|
|
191
|
+
watchDevicePosition: false,
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
}, [isReady, isEnabled, enable]);
|
|
195
|
+
|
|
196
|
+
const handleUpdatePosition = useCallback(async () => {
|
|
197
|
+
try {
|
|
198
|
+
// Update position manually
|
|
199
|
+
await update({
|
|
200
|
+
latitude: 43.6532,
|
|
201
|
+
longitude: -79.3832,
|
|
202
|
+
accuracy: 5,
|
|
203
|
+
heading: 90,
|
|
204
|
+
floorOrFloorId: floor,
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
// Enable follow mode
|
|
208
|
+
await follow('position-and-heading', {
|
|
209
|
+
zoomLevel: 19,
|
|
210
|
+
});
|
|
211
|
+
} catch (error) {
|
|
212
|
+
console.error('Failed to update position:', error);
|
|
213
|
+
}
|
|
214
|
+
}, [update, follow, floor]);
|
|
215
|
+
|
|
216
|
+
return (
|
|
217
|
+
<View>
|
|
218
|
+
<Text>Is Ready: {isReady ? 'Yes' : 'No'}</Text>
|
|
219
|
+
<Text>Is Enabled: {isEnabled ? 'Yes' : 'No'}</Text>
|
|
220
|
+
<Text>State: {state}</Text>
|
|
221
|
+
<Text>Following: {following ? 'Yes' : 'No'}</Text>
|
|
222
|
+
{position && (
|
|
223
|
+
<Text>
|
|
224
|
+
Position: {position.latitude.toFixed(4)}, {position.longitude.toFixed(4)}
|
|
225
|
+
</Text>
|
|
226
|
+
)}
|
|
227
|
+
{accuracy && <Text>Accuracy: {accuracy.toFixed(1)}m</Text>}
|
|
228
|
+
{heading && <Text>Heading: {heading.toFixed(0)}°</Text>}
|
|
229
|
+
<TouchableOpacity onPress={handleUpdatePosition}>
|
|
230
|
+
<Text>Update Position & Follow</Text>
|
|
231
|
+
</TouchableOpacity>
|
|
232
|
+
</View>
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
**Key Differences from Vanilla JS:**
|
|
238
|
+
|
|
239
|
+
- **All methods are async**: `enable()`, `disable()`, `update()`, and `follow()` return Promises
|
|
240
|
+
- **Rich state**: Hook returns `isReady`, `state`, `position`, `floor`, `following`, `accuracy`, `heading` for real-time updates
|
|
241
|
+
- **Separate event hook**: Use `useBlueDotEvent` for listening to position-update, state-change, and follow-change events
|