预期实现效果:
初始化地图之后,预期是想通过设置 view 的 center 值来指定地图中心点。
报错文案:
Type 'number[]' is missing the following properties from type 'Point': latitude, longitude, m, type, and 27 more.
报错截图:
解决方案:
通过报错文案得知,如果想设置 view.center 值的话,预期是要赋值一个 Point 类型的值。
虽然在 JS 文件中我们通过简单赋值一个包含经纬度的数组可以指定地图中心点,但是在 TS 文件中这样的做法会有类型报错,所以还是不要嫌麻烦,按照报错的建议来优化代码,如下:
import Point from '@arcgis/core/geometry/Point.js'
// ......
view.center = new Point({
latitude: 30.577203,
longitude: 104.061982
})