{"record":{"id":"c4ff42613d82036b","repo":"apache/echarts","slug":"bmap-api-is-not-loaded","errorCode":null,"errorMessage":"BMap api is not loaded","messagePattern":"BMap api is not loaded","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"extension-src/bmap/BMapCoordSys.ts","lineNumber":275,"sourceCode":"    };\n    /**\n     * @override\n     */\n    Overlay.prototype.draw = function () {};\n\n    return Overlay as BMapECExtendedOverlayCtor;\n}\n\nBMapCoordSys.create = function (ecModel, api) {\n    let bmapCoordSys: BMapCoordSys;\n    const root = api.getDom();\n\n    // TODO Dispose\n    ecModel.eachComponent(COMPONENT_MAIN_TYPE_BMAP, function (bmapModel: BMapModel) {\n        const painter = api.getZr().painter;\n        const viewportRoot = painter.getViewportRoot();\n        if (typeof BMap === 'undefined') {\n            throw new Error('BMap api is not loaded');\n        }\n        Overlay = Overlay || createOverlayCtor();\n        if (bmapCoordSys) {\n            throw new Error('Only one bmap component can exist');\n        }\n        let bmap;\n        if (!bmapModel.__bmap) {\n            // Not support IE8\n            let bmapRoot: HTMLElement = root.querySelector('.ec-extension-bmap');\n            if (bmapRoot) {\n                // Reset viewport left and top, which will be changed\n                // in moving handler in BMapView\n                viewportRoot.style.left = '0px';\n                viewportRoot.style.top = '0px';\n                root.removeChild(bmapRoot);\n            }\n            bmapRoot = document.createElement('div');\n            bmapRoot.className = 'ec-extension-bmap';","sourceCodeStart":257,"sourceCodeEnd":293,"githubUrl":"https://github.com/apache/echarts/blob/30076aedcd7b7f65d8dd8e8d9ece46ce778133a3/extension-src/bmap/BMapCoordSys.ts#L257-L293","documentation":"Thrown by the bmap (Baidu Map) extension's BMapCoordSys.create when the global BMap object is undefined at chart creation time. The bmap extension is a thin bridge that hands rendering off to the real Baidu Maps JS API, which must be loaded separately; without that API the coordinate system cannot construct the map. Unlike most ECharts assertions, this check is NOT guarded by __DEV__ and runs in production builds too.","triggerScenarios":"Calling setOption with a bmap component (or series referencing bmap) before the Baidu Maps JavaScript API <script> has finished loading. Also fires when the script tag is missing entirely, blocked by CSP, or loaded with an invalid/rejected AK (access key).","commonSituations":"Forgetting to add the Baidu Maps script tag; async/defer script not resolved before chart init; corporate network blocking api.map.baidu.com; AK key rejected or rate-limited; testing offline.","solutions":["Load the Baidu Maps API script in <head> before initializing ECharts: <script src=\"https://api.map.baidu.com/api?v=3.0&ak=YOUR_AK\"></script>","Initialize the bmap chart only after the BMap script's onload callback (or window.onload) fires","Verify the AK is valid and the runtime can reach api.map.baidu.com (check CSP / network)"],"exampleFix":"// before\nchart.setOption({ bmap: {...}, series: [...] }); // throws: BMap api is not loaded\n\n// after\n// <script src=\"https://api.map.baidu.com/api?v=3.0&ak=YOUR_AK\"></script>\nwindow.onload = () => chart.setOption({ bmap: {...}, series: [...] });","handlingStrategy":"validation","validationCode":"if (typeof (window as any).BMap === 'undefined') {\n  console.error('[bmap] Baidu Maps API not loaded; aborting setOption');\n  return;\n}\nchart.setOption(option);","typeGuard":"const isBmapLoaded = (): boolean => typeof (window as any).BMap !== 'undefined';","tryCatchPattern":null,"preventionTips":["Initialize the bmap chart only after the Baidu Maps script onload callback fires","Gate chart init behind an isBmapLoaded() check","Confirm Content-Security-Policy allows scripts from api.map.baidu.com"],"tags":["bmap-extension","baidu-maps","external-dependency","runtime"],"backgroundTag":null,"analyzedSha":"30076aedcd7b7f65d8dd8e8d9ece46ce778133a3","analyzedAt":"2026-08-12T12:42:28.134Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}