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