Implement camera controls and expose MapHandle API in MapView

This commit is contained in:
2026-01-30 23:00:14 +05:30
parent 8710bc7a7f
commit 5b04cc9a58
4 changed files with 113 additions and 6 deletions

View File

@@ -29,5 +29,26 @@ export default function App() {
}
```
## Camera Controls 🔧
This package exposes a small imperative `MapHandle` API via `ref` on `MapView`. Use it to animate the camera or fit bounds.
Example:
```ts
const mapRef = useRef<MapHandle | null>(null);
mapRef.current?.flyTo({ latitude: 37.78825, longitude: -122.4324 });
mapRef.current?.fitBounds({ latitude: 37.809, longitude: -122.410 }, { latitude: 37.779, longitude: -122.450 });
```
Available methods:
- `animateToRegion(region, duration?)` — animate to a region.
- `animateCamera(camera, options?)` — animate using camera properties.
- `flyTo(coordinate, duration?)` — quick helper that animates to a small region around `coordinate`.
- `fitBounds(northEast, southWest, options?)` — fit the two coordinates with optional `edgePadding`.
---
## Notes
- This package delegates to `react-native-maps` for platform implementations. Follow `react-native-maps` docs for iOS/Android setup (Google Maps API key, pods, manifest permissions).