【问题标题】:Proj4 - TypeError: lib_namespaceObject is not a functionProj4 - TypeError:lib_namespaceObject 不是函数
【发布时间】:2021-05-31 19:20:54
【问题描述】:

我正在尝试使用 proj4 转换一些坐标,但出现此错误

Uncaught (in promise) TypeError: lib_namespaceObject is not a function

proj4 是从 typescript 模块内部调用的。 proj4 版本:2.6.3

我的代码:

import * as proj4 from 'proj4'
import * as atlas from 'azure-maps-control';

//...

fetch('...')
  .then(response => response.json())
  .then((data: atlas.data.FeatureCollection) => {
     data.features = data.features.filter(f => f.geometry);
     data.features.forEach(f => {
       let from = "+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs";
       let to = "+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees";

       f.geometry.coordinates[0] = proj4(from, to, f.geometry.coordinates[0] as any);
       f.geometry.coordinates[1] = proj4(from, to, f.geometry.coordinates[1] as any);
     });
  });

错误出现在行:

f.geometry.coordinates[0] = proj4(from, to, f.geometry.coordinates[0] as any)

【问题讨论】:

    标签: typescript proj


    【解决方案1】:

    我现在开始工作了。不得不将导入更改为

    import proj4 from 'proj4'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-10-02
      • 2013-07-19
      • 2016-01-27
      • 2017-05-06
      • 2019-12-20
      • 1970-01-01
      • 2013-11-05
      • 2021-12-04
      相关资源
      最近更新 更多