Refactor example app and add location tracking functionality with tests

This commit is contained in:
2026-02-03 23:06:09 +05:30
parent fb56521d84
commit d1e383baf5
9 changed files with 149 additions and 150 deletions

View File

@@ -15,20 +15,24 @@ Basic usage:
```ts
import React from 'react';
import { MapView, Marker } from '@lynkedup/map-sdk';
import { MapView, Marker, useLocationTracking, Polyline } from '@lynkedup/map-sdk';
export default function App() {
const { isTracking, path, startTracking, stopTracking, clear } = useLocationTracking();
return (
<MapView
style={{ flex: 1 }}
initialRegion={{ latitude: 37.78825, longitude: -122.4324, latitudeDelta: 0.0922, longitudeDelta: 0.0421 }}
>
<MapView style={{ flex: 1 }} initialRegion={{ latitude: 37.78825, longitude: -122.4324, latitudeDelta: 0.0922, longitudeDelta: 0.0421 }}>
<Marker coordinate={{ latitude: 37.78825, longitude: -122.4324 }} />
{path.length > 1 && <Polyline coordinates={path} strokeWidth={4} strokeColor="#007AFF" />}
</MapView>
);
}
```
Tracking notes:
- `useLocationTracking()` uses the platform geolocation API (`navigator.geolocation.watchPosition`). Request permissions on iOS/Android as usual before starting tracking.
- It returns `{ isTracking, path, current, startTracking, stopTracking, clear }` so you can display the polyline and follow the user.
## Camera Controls 🔧
This package exposes a small imperative `MapHandle` API via `ref` on `MapView`. Use it to animate the camera or fit bounds.