Baidu Map v3.5 search function, and Map zoom button change Style

Source: Internet
Author: User

Search should be a relatively simple piece. Let's talk about the zoom button.
        Sets whether to display the zoom control        Mmapview.showzoomcontrols (false);
Hide the zoom control first, and then define the two buttons yourself directly on the map page.
           Case R.id.minus_sign:float Zoomlevel = Mbaidumap.getmapstatus (). Zoom;                    if (zoomlevel>4) {mbaidumap.setmapstatus (Mapstatusupdatefactory.zoomout ());                    Minus_sign.setenabled (TRUE);                Plus_sign.setenabled (TRUE);                    }else{minus_sign.setenabled (FALSE); Toast.maketext (Mainmap.this, "has shrunk to the smallest!                ", Toast.length_short). Show ();            } break;                Case R.id.plus_sign:float zoomLeve2 = Mbaidumap.getmapstatus (). Zoom;                    if (zoomleve2<=18) {mbaidumap.setmapstatus (Mapstatusupdatefactory.zoomin ());                    Plus_sign.setenabled (TRUE);                Minus_sign.setenabled (TRUE); }else{Toast.maketext (Mainmap.this, "has been put to the max!                    ", Toast.length_short). Show ();                Plus_sign.setenabled (FALSE); } break; 
The listener has two buttons to go.
Here's a look at the search this piece needs to implement these interfaces
public class Poisearchactivity extends Activity implements        Ongetpoisearchresultlistener, Ongetsuggestionresultlistener {    private poisearch mpoisearch = null;
       Create a retrieval poi instance        Mpoisearch = Poisearch.newinstance ();        Set POI retrieval Listener        Mpoisearch.setongetpoisearchresultlistener (this);

Called where the search button is listening
  Initiate a retrieval request                            mpoisearch.searchincity ((New Poicitysearchoption ())                                    . City (mycity)                                    . Keyword (editdata)                                    . Pagenum (datai++));

Incoming city, search name, number of pages, Datai starting from 0 no per click Plus One
   @Override protected void OnDestroy () {Mpoisearch.destroy ();    Super.ondestroy (); } @Override public void Ongetpoiresult (Poiresult poiresult) {if (Poiresult = = NULL | | poiresu Lt.error = = SearchResult.ERRORNO.RESULT_NOT_FOUND) {toast.maketext (poisearchactivity.this, "Results not found", Toast.leng            Th_long). Show ();        Return } if (Poiresult.error = = SearchResult.ERRORNO.NO_ERROR) {for (int i=0;i<poiresult.getallpoi (). Size ()                ; i++) {pio=new pioinfo ();                Pio.setname (Poiresult.getallpoi (). get (i). Name);                Pio.setaddress (Poiresult.getallpoi (). get (i). address);                Pio.setlocation (Poiresult.getallpoi (). get (i). location);            Mlist.add (PIO);            } stopprogressdialog ();            Dataadapter.notifydatasetchanged ();        Return } if (Poiresult.error = = SearchResult.ERRORNO.AMBIGUOUS_KEYWORD) {            When the input keyword is not found in the city but found in other cities, returns the list of cities that contain the keyword information String strinfo = "on";                For (Cityinfo cityInfo:poiResult.getSuggestCityList ()) {strinfo + = cityinfo.city;            Strinfo + = ",";            } Strinfo + = "Find results";        Toast.maketext (Poisearchactivity.this, Strinfo, Toast.length_long). Show (); }    }


So the search is done.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Baidu Map v3.5 search function, and Map zoom button change Style

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.