Micro-letter attendance for development of micro-credit Enterprise No. Baidu map positioning _javascript Tips

Source: Internet
Author: User

Previously in the micro-letter enterprise development: Micro-letter attendance in the use of Baidu map positioning components, but found in some mobile phones will appear positioning failure tips, so there is a study of Baidu map. The original use of the Web Components Baidu is not going to update, but also to check the other Baidu map of the API, there is a JavaScript API popular version, and then tried, did not expect to solve the problem.

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)//retrieve succeeded. Corresponds to the 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 ("Locate failure error code" + Status) 
  } 
 } 
</script> 

Implementation effect


The above content to share the micro-credit enterprise public number of the development of micro-letter attendance Baidu map positioning, code easy to understand, need friends to learn it quickly.

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.