Some problems encountered when using Baidu Map API and echarts

  1. Uncaught TypeError: Cannot read properties of undefined (reading 'extendComponentModel')

  • Reason: This error is usually caused by the introduction of an incompatible version of the echarts library

  • Make sure that the version of the echarts library is compatible with the API version used. It is recommended to use the online version provided by echarts.

Uncaught TypeError: Cannot read properties of undefined (reading 'extendComponentModel') at VM11821 bmap.min.js:22:2905

  • Reason: This error is usually caused by the incompatibility between the introduced Baidu Map API version and the echarts Baidu Map extended version.

  • Ensure that the echarts Baidu Map extension version is compatible with the Baidu Map API version used

  • It is recommended to use the CDN officially provided by echarts directly:

Summarize

  • If you encounter the above two errors, you can directly copy the following three lines:

  • Introduce the map api address, echarts address, and extension plug-in address through the <script> tag. The ak here is the one you registered in the map service center.

<!-- 百度 -->
    <script src="https://api.map.baidu.com/api?v=3.0&ak=?"></script>
    <!-- echarts -->
    <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts@5/dist/echarts.min.js"></script>
    <!-- 扩展地图插件 -->
    <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts@5/dist/extension/bmap.min.js"></script>

Guess you like

Origin blog.csdn.net/Edenms/article/details/129564768