高德地图报Uncaught TypeError: Cannot read property 'addressComponent' of undefined的解决办法

1、在使用官网的样例获取当前行政区的时候一直报 Uncaught TypeError: Cannot read property 'addressComponent' of undefined这个错误,如下图:

高德地图报Uncaught TypeError: Cannot read property 'addressComponent' of undefined的解决办法_第1张图片

2、经过自己分析错误及到百度上查找最终发现在使用Key必须为 Web端(JS API)这个类型,不然就会跟域名解析对不上。

如下图:

高德地图报Uncaught TypeError: Cannot read property 'addressComponent' of undefined的解决办法_第2张图片

 

3、更改之后效果正常

高德地图报Uncaught TypeError: Cannot read property 'addressComponent' of undefined的解决办法_第3张图片

 

更多精彩技术分享请浏览本人博客:https://blog.csdn.net/wohiusdashi

你可能感兴趣的:(GIS)