获取百度地图按条件查找的信息

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>数据接口</title>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=1.3"></script>
    <script src="http://fc.0372.cn/js/jquery-1.9.1.js" type="text/javascript"></script>
</head>
<body>
    <div style=" 520px; height: 340px; border: 1px solid gray" id="container">
    </div>
    <div id="results" style="font-size: 13px; margin-top: 10px;">
    </div>
    <div id="d">
    </div>
</body>
</html>
<script type="text/javascript">
    var map = new BMap.Map("container");
    var options = {
        onSearchComplete: function (results) {
            // 判断状态是否正确



            if (local.getStatus() == BMAP_STATUS_SUCCESS) {
                for (var i = 0; i < results.getNumPages(); i++) {
                    var s = [];
                    var n = results.getCurrentNumPois();
                    for (var i = 0; i < n; i++) {
                        var title = results.getPoi(i).title;
                        var address = results.getPoi(i).address;
                        //var phone = results.getPoi(i).phoneNumber;
                        var x = results.getPoi(i).point.lat;
                        var y = results.getPoi(i).point.lng;
                        $.post("GetGardenFromMap.ashx", { "title": title, "address": address,  "x": x, "y": y }, function (data,status) {
                            if ("success" == status) {
                                //alert("ok");
                            }
                            else {
                                alert("error");
                            }

                        });
                        //                     $.ajax({
                        //                         url: "map.ashx",
                        //                         data: { "title": title, "address": address, "phone": phone, "x": x, "y": y }
                        // 
                        //                     });
                        //s.push(title+", " + address + "," + phone + "," + x + "," + y + "个数" + results.getNumPois());
                        //alert(x);
                    }
                    alert(results.getPageIndex() + "/" + results.getNumPages() + "ok");
                    // document.getElementById("results").innerHTML = s.join("<br/>");
                }
            }
        },
        renderOptions: {
            map: map,
            panel: "d"

        }

    };
    var local = new BMap.LocalSearch("安阳", options);
    local.setPageCapacity(100);
    local.search("小区");

</script>
原文地址:https://www.cnblogs.com/xuhongfei/p/3431689.html