首页 > 解决方案 > Mapbox 错误:“无法读取未定义的属性 '0'”

问题描述

我正在使用构建网络地图,mapbox gl js并且一切正常,但现在不知从何而来我收到此错误:

错误 {消息:“无法读取未定义的属性 '0'”}

在此处输入图像描述

虽然它在一天前工作并且代码没有任何变化:

在此处输入图像描述

var url = 'http://localhost:3000/data';

map.addSource('features', {
  type: 'geojson',
  data: url
});

map.addLayer({
  'id': 'features-layer',
  'type': 'circle',
  'source': 'features',
  'paint': {
    'circle-color': '#ccc',
    'circle-radius': 10,
    'circle-opacity': 0.6,
    'circle-stroke-width': 0.6,
    'circle-stroke-color': 'black',
  }
});

标签: javascriptmapbox

解决方案


我认为这是因为几何对象中的“坐标”一词拼写不正确,请检查第 24 行的第一个屏幕截图


推荐阅读