Enterprise ID development: Attendance Baidu map positioning, attendance Map
Previously, I used Baidu map's positioning component in enterprise ID development: I found that some mobile phones had failed to locate the component. So I studied Baidu map. The original Web component Baidu did not intend to update it. It also re-checked other APIs of Baidu map and a popular JavaScript API version. So I tried it and did not expect it to be solved.
The core code is simple:
<Div id = "allmap"> </div> <script type = "text/javascript" src = "http://api.map.baidu.com/api? V = 2.0 & ak = kkkk "> </script> <script type =" text/javascript "> // Baidu map API function var map = new BMap. map ("allmap"); var circle = new BMap. geolocation (); circle. getCurrentPosition (locationResult); // map. addOverlay (circle); function locationResult (geolocationResult) {var Status = this. getStatus () if (Status = 0) // the query is successful. Corresponding value "0 ". {$ ("# Lng "). val (geolocationResult. point. lng); $ ("# lat "). val (geolocationResult. point. lat); var address = geolocationResult. address; $ ("# city "). val (address. city); $ ("# district "). val (address. district); $ ("# street "). val (address. street); $ ("# address "). val (address. province + address. city + address. district + address. street + address. street_number);} else {alert ("locating failed error code" + Status) }}</script>
Effect
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.