Use of the Baidu map JavaScript API

Source: Internet
Author: User
Tags rounds

Recently made its own website, call Baidu Map JS API, on the page display some coordinate points. The problem is that when the coordinate point exceeds 10, convertor.translate (Temppointarr, 1, 5, translatecallback) after execution, the state of the data in Translatecallback is not 0, It should be that the GPS longitude and latitude conversion is not completed, resulting in coordinate points will not be added to the map display. Do not know the reason, look at the API document should be able to find the answer, helpless installed AIP Broadband, now Baidu map of the JS API page can not open. It is possible to solve this problem by dividing the coordinate transformation into a group of 10.

varGroups = 0; //callback function after the coordinate conversion is completeTranslatecallback =function(data) {if(Data.status = = 0) {                             for(vari = 0; i < data.points.length; i++) {                                varMarker =NewBmap.marker (Data.points[i]); varLabel =NewBmap.label (Groups * + I,{offset:NewBmap.size (20,-10)}); Marker.setlabel (label); //add Baidu labelMap.addoverlay (marker); } groups++; Map.setcenter (Data.points[i-1]); //alert ("The Center is the:" + (i-1) + "th point");                          }                          Else{alert ("Data status is not 0"); }} setTimeout (function(){                            varConvertor =NewBmap.convertor (); varn = 10; Alert ("The Totall number of points is:" +pointarr.length); varremain = pointarr.length% 10; varRounds = (pointarr.length-remain)/10; Alert (rounds+ "groups of points and" + remain + "points to translate"); varTemppointarr = []; varindex = 0;  for(varR = 0; R < rounds; r++) {Temppointarr= [];  for(vari = 0; I < n; i++) {alert ("The index of point:" +index);                                    Temppointarr.push (Pointarr[index]); Index++; } convertor.translate (Temppointarr,1, 5, Translatecallback); } Temppointarr= [];  for(vari = 0; I < remain; i++) {alert ("The index of point:" +index);                                Temppointarr.push (Pointarr[index]); Index++; } convertor.translate (Temppointarr,1, 5, Translatecallback); }, 1000);

Use of the Baidu map JavaScript API

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.