<!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、

运用shapefile.js解析Shp文件

运用shapefile.js解析Shp文件

 

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

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

运用shapefile.js解析Shp文件

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

运用shapefile.js解析Shp文件

 

 

 

运用shapefile.js解析Shp文件

 

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

运用shapefile.js解析Shp文件

 

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

运用shapefile.js解析Shp文件

 

 修改为gb2312

 

相关文章:

  • 2021-10-26
  • 2022-12-23
  • 2021-08-14
  • 2021-11-23
  • 2021-11-23
  • 2021-12-03
  • 2021-10-07
猜你喜欢
  • 2022-02-26
  • 2022-12-23
  • 2022-12-23
  • 2022-02-01
  • 2022-12-23
  • 2022-02-10
  • 2022-01-06
相关资源
相似解决方案