Package xiaosi. baidumap; import android. app. alertdialog; import android. content. dialoginterface; import android. OS. bundle; import COM. baidu. mapapi. bmapmanager; import COM. baidu. mapapi. geopoint; import COM. baidu. mapapi. mkaddrinfo; import COM. baidu. mapapi. mkdrivingrouteresult; import COM. baidu. mapapi. mkpoiinfo; import COM. baidu. mapapi. mkpoiresult; import COM. baidu. mapapi. mksearch; import COM. baidu. mapapi. mksear Chlistener; import COM. baidu. mapapi. mktransitrouteresult; import COM. baidu. mapapi. mkwalkingrouteresult; import COM. baidu. mapapi. mapactivity; import COM. baidu. mapapi. mapcontroller; import COM. baidu. mapapi. mapview; import COM. baidu. mapapi. poioverlay; public class baidumapactivity extends mapactivity {/** called when the activity is first created. */private bmapmanager mapmanager = NULL; private string key = "Outputs"; private mapview = NULL; private mksearch; private mapcontroller = NULL; @ overridepublic void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); setcontentview (R. layout. main); mapmanager = new bmapmanager (getapplication (); mapmanager. init (Key, null); super. initmapactivity (mapmanager); mapview = (mapview) findvie Wbyid (R. id. mapview); // enables the built-in zoom control mapview. setbuiltinzoomcontrols (true); // get control of mmapview, which can be used to control and drive translation and zoom mapcontroller = mapview. getcontroller (); // sets the map zoom level mapcontroller. setzoom (12); mksearch = new mksearch (); mksearch. init (mapmanager, new mysearchlistener (); // note that only one mksearchlistener is supported. Refer to the last setting. // search for the ktvif (mksearch) near Shandong University of Science and Technology (5000. poisearchnearby ("KTV", new geopoint (INT) (36.001618315221194*1e6 ), (INT) (120.11934041976929*1e6), 5000) =-1) {system. out. println ("failed");} else {system. out. println ("succeeded") ;}} public class mysearchlistener implements mksearchlistener {public void ongetaddrresult (mkaddrinfo arg0, int arg1) {/** return address information search results. Parameter: arg0-arg1-error number of the search result. 0 indicates that the search result is correct and the result contains related results. 100 indicates that the search result is correct, no relevant address information */} public void ongetdrivingrouteresult (mkdrivingrouteresult arg0, int arg1) {/** returns the driving route search result. Parameter: arg0-arg1-error number of the search result. 0 indicates that the search result is correct */} public void ongetpoiresult (mkpoiresult arg0, int arg1, int arg2) {string result = ""; /** return the poi search result. Parameter: arg0-search result arg1-return result type: mksearch. type_poi_list mksearch. type_area_poi_list mksearch. type_city_list arg2-error number. 0 indicates that the returned result is correct */If (arg0 = NULL) {return ;}// clear all the existing covers on the map // mapview. getoverlays (). clear (); // poioverlay is the overlaypoioverlay poioverlay = new poioverlay (baidumapactivity. this, mapview); // poioverlay is displayed on the map (points of interest are marked on the map. setdata (arg0.getallpoi (); // Add a cover for the map Mapview. getoverlays (). add (poioverlay); // At the beginning, I forgot to add the code. The map has not changed, and it has been entangled for a long time. If (arg0.getnumpois ()> 0) {// set the coordinates of the location where a search result is located to mkpoiinfo poiinfo = arg0.getpoi (0); mapcontroller. setcenter (poiinfo.pt);} // traverses the search results returned by the current page (only 10 results are returned by default) for (mkpoiinfo poiinfo: arg0.getallpoi ()) {result = Result + "\ n" + "name:" + poiinfo. name + "\ n" + "Address:" + poiinfo. address + "\ n" + "City:" + poiinfo. city;} // use alertdidia to display the searched content alertdia Log. builder = new alertdialog. builder (baidumapactivity. this); builder. settitle ("search result"); builder. setmessage (result); builder. setpositivebutton ("off", new android. content. dialoginterface. onclicklistener () {public void onclick (dialoginterface diich, int which) {dialog. dismiss () ;}}); builder. show ();} public void ongettransitrouteresult (mktransitrouteresult arg0, int arg1) {/** return the bus search result. Parameter: arg0-arg1-error number of the search result. 0 indicates that a correct result is returned. When mkevent is returned. error_route_addr indicates that the start point or end point is ambiguous. Call the getaddrresult method of mktransitrouteresult to obtain the recommended start point or end point information */} public void ongetwalkingrouteresult arg0, int arg1) {/** return the walking route search result. Parameter: arg0-arg1-error number of the search result. 0 indicates that the returned result is correct */}}@ overrideprotected Boolean isroutedisplayed () {return false;} @ overrideprotected void ondestroy () {If (mapmanager! = NULL) {mapmanager. Destroy (); mapmanager = NULL;} super. ondestroy () ;}@ overrideprotected void onpause () {If (mapmanager! = NULL) {mapmanager. Stop () ;}super. onpause () ;}@ overrideprotected void onresume () {If (mapmanager! = NULL) {mapmanager. Start () ;}super. onresume ();}}