import React, { useEffect, forwardRef, useImperativeHandle } from 'react';

// 批量标注
var Markers = /*#__PURE__*/forwardRef(function (_ref, ref) {
  var map = _ref.map,
    points = _ref.points,
    onClick = _ref.onClick;
  // Expose
  useImperativeHandle(ref, function () {
    return {
      redraw: function redraw() {
        draw();
      }
    };
  });
  useEffect(function () {
    return function () {
      map.clearMarkers();
    };
    // eslint-disable-next-line
  }, []);
  useEffect(function () {
    draw();
    // eslint-disable-next-line
  }, [JSON.stringify(points)]);
  function draw() {
    var _points$, _points$2;
    if (!(points !== null && points !== void 0 && (_points$ = points[0]) !== null && _points$ !== void 0 && _points$.latitude) || !(points !== null && points !== void 0 && (_points$2 = points[0]) !== null && _points$2 !== void 0 && _points$2.longitude)) {
      return;
    }
    map.clearMarkers();
    map.addMarkers(points, {
      onClick: onClick
    });
  }
  return /*#__PURE__*/React.createElement(React.Fragment, null);
});
export default Markers;