百度地图示例

var map = new BMap.Map("l-map"); // 创建Map实例

map.centerAndZoom(new BMap.Point(114.12593,22.551984), 11);

var local = new BMap.LocalSearch('广东省', {
    renderOptions: {
        map: map,
        autoViewport: true,    
        selectFirstResult: false
    },
    pageCapacity: 20,
    onSearchComplete: function(results){      
      if (local.getStatus() == BMAP_STATUS_SUCCESS){      
            // 判断状态是否正确      
            var s = [];      
            for (var i = 0; i < results.getCurrentNumPois(); i ++){      
                s.push(results.getPoi(i).title + ", " + results.getPoi(i).uid);      
            }      
         document.getElementById("log").innerHTML = s.join("
"); } } }); //console.table(local); //console.log(BMap.LocalSearch.toString()); console.log(local); console.log(local.we); local.search('广州白云区同和中学');

你可能感兴趣的:(百度地图示例)