标签:coder component span ESS alert shu else ddc fun
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>获取浏览器城市信息及坐标</title> <script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=iuRrnwIABxxxxxxxAsxMAysHuMiF6"></script> </head> <body> <input id="province" value=""> <input id="I_Area" value=""> <script type="text/javascript"> var geoc = new BMap.Geocoder(); var native = new BMap.LocalCity(); native.get(function (r) { alert(r.name); alert("lat:" + r.center.lat + " lng:" + r.center.lng); geoc.getLocation(r.center, function (rs) { var addComp = rs.addressComponents; $("#province").val(addComp.province); if (addComp.province == addComp.city) { $("#I_Area").val(addComp.district); } else { $("#I_Area").val(addComp.city); } }); }); </script> </body> </html>
标签:coder component span ESS alert shu else ddc fun
原文地址:https://www.cnblogs.com/z-hj/p/12834967.html