typescript - Proj4 - TypeError:lib_namespaceObject 不是函数
问题描述
我正在尝试使用 proj4 转换一些坐标,但出现此错误
Uncaught (in promise) TypeError: lib_namespaceObject is not a function
proj4 从打字稿模块内部调用。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)
解决方案
我现在开始工作了。不得不将导入更改为
import proj4 from 'proj4'
推荐阅读
- mysql - 在 SQL 中将行值显示为列值
- laravel - 如何用旧的 laravel 护照替换新的 api 访问令牌
- mysql - 使用嵌套查询和内部联接清理 SQL 查询
- apache-spark - Spark 从另一个国家/地区获取当前日期
- java - 为什么我的 onStart() 函数在项目的主要活动开始时不起作用?
- python - 是否可以通过 OpenCV 本身获得视频设置的极值?
- java - 如果我添加 JButton,Java FocusListener 和 KeyListener 将不起作用
- mysql - 编写mySql命令根据性别获取元数据?
- swift - 映射组合数组时如何避免嵌套闭包?
- router - 在 cisco 路由器上为两个端口配置相同的 VLAN