javascript - 如何从 html 文件输入中加载 geojson 数据?
问题描述
我想构建允许客户端从 html 表单上传 geojson 文件的系统,这些数据将显示在传单地图上。当我尝试这样做时,它显示错误代码 405。我想提交包含geojson 文件的表单并使用leaflet-omnivore 插件加载此文件。
我的 html 文件为,
<section class="addVectorLayer">
<form action="" method="POST" class="vector">
Click to add your vector layer. It support Json, Geojson, csv, gpx and kml formats.
<input type="file" name="files" id="input_files">
</form>
</section>
我的js文件在这里,
geojson.onlode = function() {
geojson.readAsDataURL(document.getElementById('input_files').files[0]);
};
omnivore.geojson(geojson.result).addTo(map);
编辑
抱歉,这不是重复的。在这个问题中,我想使用omnivore Leaflet-plugin 读取geojson 文件。
解决方案
推荐阅读
- android - 数据库助手返回 -1
- r - 我有一个随机变量的概率分布,如何根据这个分布生成一组 10 个数字的随机数?
- java - Spring OAuth2 使用 Keycloak 自动登录
- javascript - asp net core 5中的Ajax错误请求400
- spring-boot - 级联实体的 Spring-Boot 验证 - 在 HttpResponse 中发送自定义错误
- heroku - 这是我在部署我的 streamlit 仪表板时遇到的错误
- python - Django LDAP - 无法绑定成功的连接
- python - 如何在python中调用延迟的分布式函数
- c# - 如何使用 xamarin.forms.maps android 将数据库中的数据添加到引脚中
- python - 正则表达式从字面上和被动地匹配换行符