import * as L from 'leaflet'
import 'leaflet/dist/leaflet.css'
import '@geoman-io/leaflet-geoman-free'
import '@geoman-io/leaflet-geoman-free/dist/leaflet-geoman.css'

// 定义地图实例
const newMap = (domId, option) => {
  const map = L.map(domId, option)
  return map
}

// 切片图层
const createLayers = (map, url, option) => {
  const newLeayer = L.tileLayer(url, option)
  newLeayer.addTo(map)
  return newLeayer
}
// leaflet.ChineseTmsProviders插件加载地图
const chinaLayers = (map, url, option) => {
  const chinaLeayer = L.tileLayer.chinaProvider(url, option)
  chinaLeayer.addTo(map)
  return chinaLeayer
}

export default { newMap, createLayers, chinaLayers }
