当echarts加载通过mapshaper合并后的geojson格式,会出现错误提示:Uncaught TypeError: Cannot read property 'length' of undefined

项目需求
  1. 在阿里Datav下载标准的geojson格式数据后,发现部分区域本身是一个整体,出现环形区域,通过分割线将其划成多个部分,影响地图的可视化效果。
    Eccharts加载geojson环形GeometryCollection格式的解决方案:Cannot read property ‘length‘ of undefined_数据
  2. 通过mapshaper合并后的数据格式为环形格式GeometryCollection,该格式无法正常加载
    Eccharts加载geojson环形GeometryCollection格式的解决方案:Cannot read property ‘length‘ of undefined_json格式_02
解决方案

手动调整格式,标准格式如下:
Eccharts加载geojson环形GeometryCollection格式的解决方案:Cannot read property ‘length‘ of undefined_加载_03

环形区域geojson格式

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {
        "name": "河口区"
      },
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [],
          []
        ]
      }
    }
  ]
}
Echarts加载效果

Eccharts加载geojson环形GeometryCollection格式的解决方案:Cannot read property ‘length‘ of undefined_分割线_04

将coordinates对应的内部数组,替换环形数据即可。
lockdatav Done!