首页 > Web开发 > 详细

运用shapefile.js解析Shp文件

时间:2019-11-21 16:23:37      阅读:436      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<script src="shapefile.js"></script>
<script>
 
shapefile.open("http://localhost:8181/shp/zd.shp")
  .then(source => source.read()
    .then(function log(result) {
      if (result.done) return;
      console.log(result.value);
      return source.read().then(log);
    }))
  .catch(error => console.error(error.stack));
 
</script>
</head>
</html>

  遇到的问题及解决方案(以下以IIS部署为例)

1、

技术分享图片

技术分享图片

 

解决方案:open打开的一定是一个带有http或者https的网络地址

2、HTML页面跨域访问shp文件,shp文件在IIS中无法访问

技术分享图片

 解决方案:dbf无法访问需要添加MIME类型shp无法访问需要添加MIME类型

技术分享图片

 

 

 

技术分享图片

 

3、成功解析数据但数据出现中文乱码

技术分享图片

 

解决方案:下载Shapefile.js源文件:https://unpkg.com/shapefile@0.6 下载完成后修改源文件中的数据编码类型

技术分享图片

 

 修改为gb2312

 

 

 

 

 

 

 

 

 

 

运用shapefile.js解析Shp文件

原文:https://www.cnblogs.com/heibai-ma/p/11905918.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!