Baidu map Javascript API traversal search Results __java

Source: Internet
Author: User

API Documentation: Http://developer.baidu.com/map/jshome.htm

But the description is not detailed enough, here is a complete example of traversing the search results.

 

(1) Here need to quote Baidu Map API, official documents

    <title> Baidu map </title>
(2) Define the page elements that save the map
</body>

The

(3) Creates a map object and initializes it, and initialization is necessary, otherwise no action can be made.

<script type= "Text/javascript" > var ls = new Bmap.localsearch (map);
        function Onsearchcomplete (result) {var n = Result.getnumpois ()) that defines the completion of each page results load
        var tab = document.getElementById ("Courtlist");
        var msg = document.getElementById ("errmsg");

        var i = 0;
            for (i = 0; i < Result.getcurrentnumpois (); i++) {var tr = tab.insertrow (tab.rows.length);

            var poi = Result.getpoi (i);
            Tr.insertcell (0). innertext = i + ls.getpagecapacity () * Result.getpageindex ();
            Tr.insertcell (1). innertext = Poi.title;
            Tr.insertcell (2). innertext = POI.POINT.LNG;
            Tr.insertcell (3). innertext = Poi.point.lat;
            Tr.insertcell (4). innertext = Poi.phonenumber;
            Tr.insertcell (5). innertext = poi.address;
        Tr.insertcell (6). innertext = Poi.tags;
           //Judge whether to the last page, if yes then no longer search if (Result.getpageindex () < Result.getnumpages ()-1) Ls.gotopage (Result.getpageindex () + 1);
    } ls.setsearchcompletecallback (Onsearchcomplete);
    Ls.setpagecapacity (100);
Ls.search ("key Words"); </script>
(4) Define search. When the Localsearch.search method is invoked, only the results of the first page are given, and if the subsequent lookup must be retrieved using Localsearch.gotopage, the callback function will be invoked for each page result load completion
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.