"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _maps = _interopRequireDefault(require("@rnmapbox/maps"));
var _config = require("../config");
var _react = _interopRequireWildcard(require("react"));
var _MapContext = require("../modules/MapContext");
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
 * Camera props
 * @category Props
 */

/**
 * @category Component
 */
const Camera = props => {
  const {
    map
  } = (0, _react.useContext)(_MapContext.MapContext);
  const mpCameraRef = (0, _react.useRef)(null);
  const {
    zoom = _config.defaultZoom,
    maxzoom = _config.defaultMaxZoom,
    minzoom = _config.defaultMinZoom,
    center = _config.defaultCenterCoordinates,
    heading,
    pitch,
    bounds,
    followLocation,
    followZoomLevel,
    followPitch,
    followHeading,
    onChange
  } = props;
  if (onChange) {
    map?.on('cameraChanged', onChange);
  }
  (0, _react.useEffect)(() => {
    mpCameraRef.current && map?.setCamera(mpCameraRef.current);
  }, [map, mpCameraRef]);
  return /*#__PURE__*/_react.default.createElement(_maps.default.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
  });
};
var _default = exports.default = Camera;
//# sourceMappingURL=Camera.js.map