网站改https不论为了安全还赶趋势,眼见越来越多的站长使用。小编在改蚂蚁分类信息的过程中就碰到发布信息没法使用百度地图一直显示“loading...”。
首先看了下控制台有报错“mixed content: the page at 'xxx' was loaded over https, but requested an insecure script 'http://api.map.baidu/api?v=1.4'. this request has been blocked; the content must be served over https.”
查了下文档1.4的不支持https,只有api v2.0版的js调用支持https。
改下后台地图的api地址:https://api.map.baidu/api?v=2.0&ak=你的密钥&s=1后面&s=1千万不可省略。地图其它设置不变。保存就可以正常使用了。
注意:2.0的是要申请密钥的申请地址:http://lbsyun.baidu/apiconsole/key