import Mapbox from '@rnmapbox/maps';
import { defaultCenterCoordinates, defaultMaxZoom, defaultMinZoom, defaultZoom } from '../config';
import { useContext, useEffect, useRef } from 'react';
import { MapContext } from '../modules/MapContext';
import React from 'react';
/**
 * Camera props
 * @category Props
 */

/**
 * @category Component
 */
const Camera = props => {
  const {
    map
  } = useContext(MapContext);
  const mpCameraRef = useRef(null);
  const {
    zoom = defaultZoom,
    maxzoom = defaultMaxZoom,
    minzoom = defaultMinZoom,
    center = defaultCenterCoordinates,
    heading,
    pitch,
    bounds,
    followLocation,
    followZoomLevel,
    followPitch,
    followHeading,
    onChange
  } = props;
  if (onChange) {
    map?.on('cameraChanged', onChange);
  }
  useEffect(() => {
    mpCameraRef.current && map?.setCamera(mpCameraRef.current);
  }, [map, mpCameraRef]);
  return /*#__PURE__*/React.createElement(Mapbox.Camera, {
    ref: mpCameraRef,
    zoomLevel: zoom,
    maxZoomLevel: maxzoom
    // Camera的默认定位动画执行周期设置为0，否则和Location自动定位冲突
    ,
    animationDuration: 0,
    minZoomLevel: minzoom,
    followUserLocation: followLocation,
    bounds: bounds,
    pitch: pitch,
    followZoomLevel: followZoomLevel,
    followHeading: followHeading,
    followPitch: followPitch,
    centerCoordinate: center,
    heading: heading
  });
};
export default Camera;
//# sourceMappingURL=Camera.js.map