WeChat enterprise ID development: WeChat attendance Baidu map positioning, attendance Map

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.