调用百度报Cannot read property ‘lng‘ of null错误

简介: 调用百度报Cannot read property ‘lng‘ of null错误

出错就是因为没有设置地图中心跟缩放等级
我用的是步行路线规划,在search之前加上centerAndZoom就没问题了
image.png

        var map = new BMap.Map("container");
        map.centerAndZoom(new BMap.Point(116.404, 39.915), 14);  //初始化地图
        var walking = new BMap.WalkingRoute(map, {
            renderOptions: {
                map: map,
                autoViewport: true
            }
        });
        // 地图的点击事件
        map.addEventListener('click', function (e) {
            var start = new BMap.Point(116.32427538375525, 39.98192077362723); //假定当前的位置在这里   海淀黄庄 
            var end = new BMap.Point(e.point.lng, e.point.lat);
            walking.search(start, end);
        });
相关文章
|
7月前
|
JavaScript API
【Vue】Cannot set reactive property on undefined,null,or primitive value:undefined
【Vue】Cannot set reactive property on undefined,null,or primitive value:undefined
110 0
|
4天前
|
Docker 容器
百度搜索:蓝易云【docker启动报错:Cannot connect to the Docker daemon】
通过以上方法,你应该能够解决“Cannot connect to the Docker daemon”错误,并成功启动Docker。如果问题仍然存在,可能需要检查其他系统配置或查看Docker日志以找出具体原因。
44 2
|
4天前
|
Java
Error:(15, 13) java: No property named “id” exists in source parameter(s). Did you mean “null”?
Error:(15, 13) java: No property named “id” exists in source parameter(s). Did you mean “null”?
36 1
|
4天前
|
缓存 Linux
百度搜索:蓝易云【Centos报错:[Errno 12] Cannot allocate memory怎么解决?】
请注意,如果内存不足的问题持续出现,建议考虑升级系统的物理内存或优化系统配置,以确保系统具有足够的资源来运行应用程序和服务。
39 0
|
4天前
|
开发工具
百度搜索:蓝易云【使用vim编辑器,进行保存时报错:E382: Cannot write, ‘buftype‘ option is set详解。】
请注意,'buftype'选项的设置通常是由于某些插件或配置文件导致的。如果您在Vim的配置文件(如.vimrc)或使用的插件中设置了'buftype'选项,请检查相关配置并确保设置正确。
44 0
|
4天前
|
JavaScript API
Property ‘proxy‘ does not exist on type ‘ComponentInternalInstance | null‘.ts
Property ‘proxy‘ does not exist on type ‘ComponentInternalInstance | null‘.ts
|
6月前
|
JavaScript
TypeError: Cannot read properties of null (reading 'level')
# 一、分析问题 1、一个下拉框组件的更新由另一个下拉框组件控制被动更新列表,子级下拉框的值是由父级下拉框的值调用接口获取,每次父级下拉框值的改变都会改变子级下拉框的数据源也就是会改变子级下拉框的options,切换后之前的父级节点找不到就会报了这个错,父级节点不改变(即不切换)的话不会报错 # 二、解决方案 ## 1、vue页面的html层 ```html <div> <el-row :gutter="15"> <el-col :span="4"> <div">父级下拉框:</div> <el-select clearable v-model="parentId" @c
86 0
|
7月前
|
缓存 Cloud Native JavaScript
猫头虎的技术博客:解决npm报错 npm ERR! Cannot read properties of null (reading ‘pickAlgorithm‘)报错问题
猫头虎的技术博客:解决npm报错 npm ERR! Cannot read properties of null (reading ‘pickAlgorithm‘)报错问题
134 0
|
4天前
|
机器学习/深度学习 SQL 关系型数据库
【MySQL进阶之路丨第十一篇】一文带你精通MySQL NULL值处理、正则表达式
【MySQL进阶之路丨第十一篇】一文带你精通MySQL NULL值处理、正则表达式
42 0
|
4天前
|
SQL 关系型数据库 MySQL
总结 vue3 的一些知识点:MySQL NULL 值处理
总结 vue3 的一些知识点:MySQL NULL 值处理