// Create bmap,amap,etc map to use invoke api
function createCurrentMap(container) {
  var _center$, _center$2;
  var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
    center = _ref.center;
  // center for search feature
  var wgs84Center = null;
  // Get the first point if array center
  if (center !== null && center !== void 0 && center.longitude && center !== null && center !== void 0 && center.latitude) {
    wgs84Center = center;
  } else if (Array.isArray(center) && center.length && (_center$ = center[0]) !== null && _center$ !== void 0 && _center$.longitude && (_center$2 = center[0]) !== null && _center$2 !== void 0 && _center$2.latitude) {
    var _center$3, _center$4;
    wgs84Center = {
      longitude: (_center$3 = center[0]) === null || _center$3 === void 0 ? void 0 : _center$3.longitude,
      latitude: (_center$4 = center[0]) === null || _center$4 === void 0 ? void 0 : _center$4.latitude
    };
  }

  // Map instance
  var currentMap = null;

  // Init google map
  if (window.google) {
    var googleCenter = new window.google.maps.LatLng(wgs84Center.longitude, wgs84Center.latitude);
    currentMap = new window.google.maps.Map(container, {
      center: googleCenter,
      zoom: 5,
      mapTypeId: window.google.maps.MapTypeId.ROADMAP
    });
  }
  // Init baidu map
  else if (window.BMap) {
    // currentMap不需要展示, 搜索时会panTo, 所以点在什么位置并不重要
    var bmapCenter = new window.BMap.Point(wgs84Center.longitude, wgs84Center.latitude);
    currentMap = new window.BMap.Map(container);
    currentMap.centerAndZoom(bmapCenter, 12);

    // 禁用地图拖拽
    currentMap.disableDragging();

    // 禁用地图缩放
    currentMap.disableScrollWheelZoom();
    currentMap.disableDoubleClickZoom();
    currentMap.disablePinchToZoom();
  }
  return currentMap;
}
export default createCurrentMap;