Typescript Proj4-TypeError:lib_namespaceObject不是函数
我试图用proj4转换一些坐标,但是我得到了这个错误Typescript Proj4-TypeError:lib_namespaceObject不是函数,typescript,proj,Typescript,Proj,我试图用proj4转换一些坐标,但是我得到了这个错误 Uncaught(in promise)类型错误:lib_namespaceObject不是函数 proj4是从typescript模块内部调用的。 proj4版本:2.6.3 我的代码: import * as proj4 from 'proj4' import * as atlas from 'azure-maps-control'; //... fetch('...') .then(response => response
Uncaught(in promise)类型错误:lib_namespaceObject不是函数
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])
我现在让它工作了。必须将导入更改为
import proj4 from 'proj4'