使用百度地图 进行逆地址解析
<!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <style type="text/css"> body, html{width: 100%;height: 100%;margin:0;font-family:"微软雅黑";font-size:14px;} #allmap {width:100%;height:100%;} </style> <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=这里填写百度key"></script> <title>逆地址解析</title> </head> <body> <div id="allmap"></div> <script type="text/javascript" > function map_click(lng,lat){ var map = new BMap.Map("allmap"); var point = new BMap.Point(lng,lat); // map.centerAndZoom(point,12); var geoc = new BMap.Geocoder(); geoc.getLocation(point,function(rs){ var addComp = rs.addressComponents; console.log(addComp); alert(addComp.province + addComp.city + addComp.district + addComp.street + addComp.streetNumber); }); } map_click(116.38,39.90); //参数解析 //@parameter1 lng 传入的经度 //@parameter2 lat 传入的纬度 </script> </body> </html>