NaverMapView distinguishes between props used for initial setup and those used for active control:
- Initial props (
initialCamera, initialRegion): Applied only when the map is first loaded. Use these if you want to set a starting position but allow the user to move the map freely without your app forcing it back. - Controlled props (
camera, region): The map will move to these values whenever the props change. Use these for full programmatic control or when syncing map state with React state.
Performance Tip: onCameraChanged is called frequently during user interaction. It is highly recommended to use a debounce function to prevent excessive state updates or API calls.
// Controlled pattern: Syncing state with map movement
const [camera, setCamera] = useState<Camera>({
latitude: 37.5665,
longitude: 126.9780,
zoom: 14,
});
<NaverMapView
camera={camera}
onCameraChanged={({ latitude, longitude, zoom, bearing, tilt }) => {
setCamera({ latitude, longitude, zoom, bearing, tilt });
}}
/>