Solutions for GPS and base station location correction on Baidu Map

Source: Internet
Author: User

1. Add the convertor. JS File

<script type="text/javascript" src="http://api.map.baidu.com/getscript?v=1.4"></script><script type="text/javascript" src="http://dev.baidu.com/wiki/static/map/API/examples/script/convertor.js"></script>

 

2. Add Baidu map Annotation

Function loadmarker (X, Y, oap_name) {If (! X) {return} // correct the GPS deviation var iconv = ".. /.. /.. /icons/access_point_b64.gif "; var iconu = ".. /.. /.. /icons/access_point_r64.gif "; var iconsize = new bmap. size (64, 64); // mark the image size var offsetsize = new bmap. size (32, 32); // offset bit // var point = new bmap. point (x, y); var icon = new bmap. icon (iconv, iconsize, {anchor: offsetsize}); translatecallback = function (point) {map. clearoverlays (); map. setcenter (point); var marker = new bmap. marker (point, {icon: icon}); marker. addeventlistener ("Mouseover", function () {This. seticon (New bmap. icon (iconu, iconsize, {anchor: offsetsize}) ;}); marker. addeventlistener ("mouseout", function () {This. seticon (New bmap. icon (iconv, iconsize, {anchor: offsetsize}) ;}); map. centerandzoom (point, 16); map. addoverlay (Marker); var GC = new bmap. geocoder (); var infowindow1 = NULL; GC. getlocation (point, function (RS) {var addcomp = Rs. addresscomponents; infowindow1 = new bmap. infowindow ("<Div style = 'margin-top: 13px; font-size: 15px; color: red; font-weight: bold; '> "+ oap_name +" </div> <Div style = 'margin-top: 5px; font-size: 13px;'> address: "+ addcomp. province + addcomp. city + addcomp. district + addcomp. street + addcomp. streetnumber + "<br/> longitude:" + x + "<br/> latitude:" + Y + "</div>"); marker1.openinfowindow (infowindow1 );}); marker. addeventlistener ("click", function () {This. openinfowindow (infowindow1) ;}) ;}bmap. convertor. translate (New bmap. point (x, y), 0, translatecallback );}

3. The final result is as follows:

Success.

Solutions for GPS and base station location correction on Baidu Map

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.