{"record":{"id":"378baa8825587987","repo":"apache/echarts","slug":"invalid-geojson-format","errorCode":null,"errorMessage":"Invalid geoJson format\n{}","messagePattern":"Invalid geoJson format\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/coord/geo/GeoJSONResource.ts","lineNumber":107,"sourceCode":"\n        return {\n            regions: finalRegions,\n            boundingRect: parsed.boundingRect || new BoundingRect(0, 0, 0, 0),\n            regionsMap: regionsMap\n        };\n    }\n\n    private _parseToRegions(nameProperty: string): GeoJSONRegion[] {\n        const mapName = this._mapName;\n        const geoJSON = this._geoJSON;\n        let rawRegions;\n\n        // https://jsperf.com/try-catch-performance-overhead\n        try {\n            rawRegions = geoJSON ? parseGeoJson(geoJSON, nameProperty) : [];\n        }\n        catch (e) {\n            throw new Error('Invalid geoJson format\\n' + e.message);\n        }\n\n        fixNanhai(mapName, rawRegions);\n\n        each(rawRegions, function (region) {\n            const regionName = region.name;\n\n            fixTextCoord(mapName, region);\n            fixDiaoyuIsland(mapName, region);\n\n            // Some area like Alaska in USA map needs to be tansformed\n            // to look better\n            const specialArea = this._specialAreas && this._specialAreas[regionName];\n            if (specialArea) {\n                region.transformTo(\n                    specialArea.left, specialArea.top, specialArea.width, specialArea.height\n                );\n            }","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/apache/echarts/blob/30076aedcd7b7f65d8dd8e8d9ece46ce778133a3/src/coord/geo/GeoJSONResource.ts#L89-L125","documentation":"Runtime (NOT dev-only) error in GeoJSONResource._parseToRegions: when registering a GeoJSON map via echarts.registerMap, the JSON is parsed into regions by parseGeoJson. If parseGeoJson throws (malformed GeoJSON structure, unsupported geometry type, missing coordinates), the error message is wrapped and re-thrown as 'Invalid geoJson format'. Fires in production.","triggerScenarios":"Passing malformed GeoJSON (wrong feature/geometry type, missing coordinates array, invalid structure) to echarts.registerMap; truncated or corrupted map JSON; passing TopoJSON instead of GeoJSON.","commonSituations":"Hand-edited GeoJSON; down-sampled/corrupted map file; wrong format (TopoJSON); GeoJSON produced by a non-conformant exporter.","solutions":["Validate the GeoJSON with a linter (geojsonlint.com or a library like @turf/helpers) before registerMap","Use an authoritative map source (e.g. the echarts map repo)","Convert TopoJSON to GeoJSON (topojson-client featurecollection) first"],"exampleFix":"// before\necharts.registerMap('foo', brokenOrTopoJson);\n\n// after\necharts.registerMap('foo', validatedGeoJsonFeatureCollection);","handlingStrategy":"try-catch","validationCode":"function isFeatureCollection(v: any): boolean {\n  return v && v.type === 'FeatureCollection' && Array.isArray(v.features)\n    && v.features.every((f: any) => f && f.type === 'Feature' && f.geometry);\n}\nif (!isFeatureCollection(geo)) throw new Error('input is not a valid GeoJSON FeatureCollection');","typeGuard":"const isFeatureCollection = (v: any): v is GeoJSON.FeatureCollection =>\n  v != null && v.type === 'FeatureCollection' && Array.isArray(v.features);","tryCatchPattern":"try {\n  echarts.registerMap('foo', geo);\n} catch (e) {\n  if (/geoJson/i.test((e as Error).message)) {\n    console.error('map registration failed; GeoJSON is malformed', e);\n  } else {\n    throw e;\n  }\n}","preventionTips":["Lint GeoJSON (geojsonlint.com or @turf) before registerMap","Use canonical map sources rather than hand-edited files","Convert TopoJSON to GeoJSON before registering"],"tags":["geo","geojson","map","runtime","data-validation"],"backgroundTag":null,"analyzedSha":"30076aedcd7b7f65d8dd8e8d9ece46ce778133a3","analyzedAt":"2026-08-12T12:42:28.134Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}