需要在html中引入依赖包
<script src='//api.tiles.mapbox.com/mapbox.js/plugins/leaflet-omnivore/v0.3.1/leaflet-omnivore.min.js'></script>

 <el-upload
    class="upload-demo"
    :before-upload="onBeforeUploadImage"
    action="string"
    multiple>
  <el-button size="mini">导入</el-button>
</el-upload>
parseKml(file){
  let result= window.URL.createObjectURL(file)
  omnivore.kml(result).addTo(this.map)//这里我的map主体
},
onBeforeUploadImage(file){
  if(file.name.endsWith('kml')){
    this.parseKml(file)
    return
  }
},

友人A
81 声望11 粉丝