Android google map multiply markers from api -


i list of car workshops api , after clicking on 1 of options list offers google map , shows marker of workshop information , question how not closing map , see other places marked markers , not chosen.

api if need: http://gdetut.com/api/firms?salt=63926e380bdc96ef990d57898daeb71c&category_id=1

map activity:

public class mapactivity extends appcompatactivity implements onmapreadycallback {  private static final string log_tag = "mylogs"; marker marker; string nameofplace; string categoryofplace; string ratingofplace; double lon; double lat;   @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_map);       places places = (places) getintent().getextras().getserializable("key");     nameofplace = places.getname();     categoryofplace = places.getsubcategory_name();     ratingofplace = places.getrating();     lon = double.parsedouble(places.getlon());     lat = double.parsedouble(places.getlat());      ((supportmapfragment) getsupportfragmentmanager().findfragmentbyid(r.id.map)).getmapasync(this);   }   //               load map , set marker @override public void onmapready(final googlemap map) {      marker = map.addmarker(new markeroptions()             .position(new latlng(lat, lon))             .title(nameofplace)             .snippet(categoryofplace + "Рейтинг:" + ratingofplace));       marker.showinfowindow();      map.setinfowindowadapter(new googlemap.infowindowadapter() {         @override         public view getinfowindow(marker marker) {              return null;         }  //                         set view marker info         @override         public view getinfocontents(marker marker) {             view v = getlayoutinflater().inflate(r.layout.marker_info, null);               textview mn = (textview) v.findviewbyid(r.id.marker_name_id);             textview mc = (textview) v.findviewbyid(r.id.marker_category_id);             textview mr = (textview) v.findviewbyid(r.id.marker_rating_id);             if (mn != null) {                 mn.settext(nameofplace);             }             if (mc != null) {                 mc.settext(categoryofplace);             }             if (mr != null) {                 mr.settext("Рейтинг: " + ratingofplace);             }               return v;         }     });       if (activitycompat.checkselfpermission(this, manifest.permission.access_fine_location) != packagemanager.permission_granted && activitycompat.checkselfpermission(this, manifest.permission.access_coarse_location) != packagemanager.permission_granted) {         return;     } //        zooming camera     map.movecamera(cameraupdatefactory.newlatlngzoom(new latlng(lat, lon), 10));     map.animatecamera(cameraupdatefactory.zoomto(17), 2000, null);     map.setmylocationenabled(true);     log.d(log_tag, "map load");    }   } 

places class:

public class places implements serializable {   string name; string geometry_name; string rating; string subcategory_name; string favorite; string csv_image; string lon; string lat;  public places(string name, string geometry_name, string rating, string subcategory_name, string favorite, string csv_image, string lon, string lat) {     this.name = name;     this.geometry_name = geometry_name;     this.rating = rating;     this.subcategory_name = subcategory_name;     this.favorite = favorite;     this.csv_image = csv_image;     this.lon = lon;     this.lat = lat;  }   public string getname() {     return name; }  public void setname(string name) {     this.name = name; }   public string getgeometry_name() {     return geometry_name; }  public void setgeometry_name(string geometry_name) {     this.geometry_name = geometry_name; }  public string getrating() {     return rating; }  public void setrating(string rating) {     this.rating = rating; }  public string getsubcategory_name() {     return subcategory_name; }  public void setsubcategory_name(string subcategory_name) {     this.subcategory_name = subcategory_name; }  public string getfavorite() {     return favorite; }  public void setfavorite(string favorite) {     this.favorite = favorite; }  public string getcsv_image() {     return csv_image; }  public void setcsv_image(string csv_image) {     this.csv_image = csv_image; }  public string getlon() {     return lon; }  public void setlon(string lon) {     this.lon = lon; }  public string getlat() {     return lat; }  public void setlat(string lat) {     this.lat = lat;  } } 

retrofit success:

    //               data retrofit     retrofit.getplaces(new callback<list<places>>() {         @override         public void success(final list<places> places, response response) {   //                save data internal storage             fileoutputstream fos = null;             try {                 fos = openfileoutput("countries_file", context.mode_private);                 objectoutputstream oos = new objectoutputstream(fos);                 oos.writeobject(places);                 oos.close();                 log.d(log_tag, "сохранение данных во внутреннюю память");             } catch (filenotfoundexception e) {                 e.printstacktrace();             } catch (ioexception e) {                 e.printstacktrace();             }  //                initialize adapter             listview.setadapter(new myadapter(mainactivity.this, places));             listview.setonitemclicklistener(new adapterview.onitemclicklistener() {                 @override                 public void onitemclick(adapterview<?> parent, view view, int position, long id) {                     intent mintent = new intent(mainactivity.this, mapactivity.class);                     places plasez = places.get(position);                     mintent.putextra("key", plasez);                     startactivity(mintent);                 }             });           } 


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -