leaflet加载kml文件
文章目录
需要在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
}
},
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论