android - MapActivity is not showing list -


i developing scenario in have show addresses of nearest location in listview on mapactivity. after running code list not appear on mapactivity.

here code:

public class gmapactivity extends com.google.android.maps.mapactivity implements onclicklistener{      mapview _mapview;     private static  int latitudee6 = 37985339;     private static  int longitudee6 = 23716735;     private gpslistener _gpslister=new gpslistener();     list<overlay> overlaylist;      mapcontroller controller;      button _cancelbtn;      string returnaddress = "";      listview locationlistview;     arraylist<string> locationaddressarraylist=new arraylist<string>();     arrayadapter<string> locationadapter;      locationlistadapter locationlistadapter;      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.mapscreen);          _mapview=(mapview)findviewbyid(r.id.mapview);         _mapview.setbuiltinzoomcontrols(true);          _cancelbtn=(button)findviewbyid(r.id.cancel_button);         _cancelbtn.setonclicklistener(this);          locationlistview=(listview)findviewbyid(r.id.location_listview);         /*locationadapter=new arrayadapter<string>(gmapactivity.this, android.r.layout.simple_list_item_1, locationaddressarraylist);*/         locationlistadapter=new locationlistadapter(gmapactivity.this, locationaddressarraylist);         locationaddressarraylist.add("rnt marg");         locationaddressarraylist.add("rnt marg");         locationaddressarraylist.add("rnt marg");         locationaddressarraylist.add("rnt marg");         locationaddressarraylist.add("rnt marg");         locationaddressarraylist.add("rnt marg");         locationlistview.setadapter(locationlistadapter);         ///////////////start gps/////////////////         if(constant.isgpsstarted==false){             startgps();             latitudee6=(int)constant.latitudevalue;             longitudee6=(int)constant.longitudevalue;         }         //getaddress(constant.latitudevalue, constant.longitudevalue);         /////////////////////////////////////////          ////////////////////////////////get nearest locations/////////////////////////////         locationmanager locationmanager = (locationmanager) gmapactivity.this                 .getsystemservice(context.location_service);         locationlistener    locationlistener = new locationlistener() {             public void onstatuschanged(string provider, int status,                     bundle extras) {             }              public void onproviderenabled(string provider) {             }              public void onproviderdisabled(string provider) {             }              public void onlocationchanged(location location) {                 double l1 = location.getlatitude();                 double l2 = location.getlongitude();                 //getaddress(l1, l2);             }         };          locationmanager.requestlocationupdates(                 locationmanager.network_provider, 0, 0, locationlistener);           //////////////////////////////////////////////////////////////////////////////////         list mapoverlays = _mapview.getoverlays();         drawable drawable = this.getresources().getdrawable(r.drawable.mapping);         customitemizedoverlay itemizedoverlay =                 new customitemizedoverlay(drawable, this);          geopoint point = new geopoint(latitudee6, longitudee6);         overlayitem overlayitem =                 new overlayitem(point, ""+constant.latitudevalue, ""+constant.longitudevalue);          itemizedoverlay.addoverlay(overlayitem);         mapoverlays.add(itemizedoverlay);          mapcontroller mapcontroller = _mapview.getcontroller();          mapcontroller.animateto(point);         mapcontroller.setzoom(6);          /*overlaylist = _mapview.getoverlays();         drawable drawable = this.getresources().getdrawable(r.drawable.mapping);         custompinpoint itemizedoverlay = new custompinpoint(drawable,this);           double lat_coordinates[] ={27.700556,28.2642635,30.0018168,29.776669,29.4096819,29.4560611};         double lng_coordinates[] ={85.3630,83.9735195,80.7382742,81.2518833,81.8115051,80.5403779};         string place_name[] ={"kathmandu","pokhara","darchula","bajhang","bajura","baitadi"};         string place_info[] ={"its capital of nepal","its , tourist place of nepal","its 1 of beautiful place in country side","chd district target:10 51,960, vdcs/muncipalities reported:41/41","chd district target: 71,280, vdcs/muncipalities reported: 47/47","chd district target:10 51,960, vdcs/muncipalities reported:41/41","chd district target: 71,280, vdcs/muncipalities reported: 7/7","chd district target:10 21,960, vdcs/muncipalities reported:44/41","chd district target: 33,3123, vdcs/muncipalities reported: 47/47"};          try{             for(int i=0; i<place_name.length; i++)             {                 geopoint point = new geopoint((int)(lat_coordinates[i]*1e6),(int)(lng_coordinates[i]*1e6));                 overlayitem overlayitem = new overlayitem(point, place_name[i], place_info[i]);                 itemizedoverlay.addoverlay(overlayitem);             }         }catch(nullpointerexception e){             e.getstacktrace();          }         finally{             overlaylist.add(itemizedoverlay);         }          controller = _mapview.getcontroller();         controller.animateto(new geopoint((int)(lat_coordinates[0]*1e6),(int)(lng_coordinates[0]*1e6)));         controller.setzoom(8);*/     }      //start gps     public void startgps(){         constant.isgpsstarted = true;         _gpslister.startgpscallback(gmapactivity.this);         _gpslister.stopgpscallback();         _gpslister.startgpscallbackagain(gmapactivity.this);     }      @override     protected boolean isroutedisplayed() {         // todo auto-generated method stub         return false;     }      public void onclick(view v) {         switch (v.getid()) {         case r.id.cancel_button:             this.finish();             break;          default:             break;         }     }      public void getnearestlocations(){      }      private void getaddress(final double lat, final double lon) {         constant.progressdialog = progressdialog.show(gmapactivity.this,"", "please wait...");         new thread(){             public void run() {                 geocoder geocoder = new geocoder(gmapactivity.this, locale.english);                 list<address> addresses = null;                 try {                     addresses = geocoder.getfromlocation(lat, lon, 1);                     if (!addresses.equals(null)) {                         address returnedaddress = addresses.get(0);                         stringbuilder strreturnedaddress = new stringbuilder("\n");                         (int = 0; < returnedaddress.getmaxaddresslineindex(); i++) {                              locationaddressarraylist.add((string)returnedaddress.getaddressline(i));                              strreturnedaddress                             .append(returnedaddress.getaddressline(i)).append(                                     "\n");                         }                         returnaddress = "around: " + strreturnedaddress.tostring();                     } else {                         returnaddress = "no address returned!";                     }                 } catch (ioexception e) {                     e.printstacktrace();                     returnaddress = "location: https://maps.google.co.in/maps?hl=en&q=" + lat                             + "," + lon;                 } catch (nullpointerexception e) {                     e.printstacktrace();                     returnaddress = lat + "," + lon;                 }                  runonuithread(new runnable() {                     public void run() {                         locationadapter.notifydatasetchanged();                         locationlistview.setadapter(locationadapter);                         constant.progressdialog.cancel();                     }                 });             };         }.start();          //  return returnaddress;     } } 

this library deprecated.

version 1 of google maps android api has been officially deprecated of december 3rd, 2012. means march 18th, 2013 no longer able request api key version. no new features added google maps android api v1. however, apps using v1 continue work on devices. existing , new developers encouraged use google maps android api v2.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -