function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import Mapbox from '@rnmapbox/maps';
import { useImperativeHandle, useRef } from 'react';
import React from 'react';
/**
 * VectorSource props
 *
 * @category Props
 */

/**
 * 支持tileJSON矢量瓦片渲染的数据来源
 *
  @category Component
 */
const VectorSource = /*#__PURE__*/React.forwardRef((props, ref) => {
  const {
    minZoom,
    maxZoom,
    children,
    hitbox = [44, 44],
    onPress,
    ...others
  } = props;
  const rnSource = useRef();
  useImperativeHandle(ref, () => ({
    queryFeatures: async layers => {
      const features = await rnSource.current?.features(layers);
      return features;
    }
  }));
  return /*#__PURE__*/React.createElement(Mapbox.VectorSource, _extends({
    ref: rnSource
  }, others, {
    minZoomLevel: minZoom,
    maxZoomLevel: maxZoom,
    hitbox: {
      width: hitbox[0],
      height: hitbox[1]
    },
    onPress: e => {
      onPress?.({
        features: e.features,
        coordinates: [e.coordinates.longitude, e.coordinates.latitude],
        point: [e.point.x, e.point.y]
      });
    }
  }), children);
});
export default VectorSource;
//# sourceMappingURL=VectorSource.js.map