日期:2014-05-16  浏览次数:20322 次

懂JS的速度进来看一下,送分了,在线等!
调用一个百度的api:

var map = new BMap.Map("container");          // 创建地图实例
map.enableScrollWheelZoom();                  //启用滚轮放大缩小;
map.addEventListener("click", function(e)
       {  
                 GetBusStation(116.384628,39.995211,1);
//                 console.log(bus_data);
       });

function GetBusStation(la,lo,i)
         {
            var mPoint = new BMap.Point(la , lo);
            map.centerAndZoom(mPoint,15);
            var circle = new BMap.Circle(mPoint,1000,{fillColor:"white", strokeWeight: 1 ,fillOpacity: 0.2, strokeOpacity: 0.3});
            map.addOverlay(circle);                                                                                  //往地图上添加圆形覆盖物;
            var local =  new BMap.LocalSearch(map, {renderOptions: {map: map, autoViewport: false}});
            var bounds = getSquareBounds(circle.getCenter(),circle.getRadius());
            local.searchInBounds("公交站",bounds); 
            var SearchResult = new Array();
            local.setSearchCompleteCallback(function(SearchResult)
           {
              console.log(local.getResults());
              console.log(SearchResult.Bh[0].title);
           });  
//              bus_data = SearchResult.Bh[0].title; 
//              console.log(bus_data);
//              return bus_data;
         }
           
            function getSquareBounds(centerPoi,r)
           {
            var