Marker is not removing from mapV2 android -


i adding maker on touch of map , want remove marker on click of button marker not removing map .here code

    // marker of end point marker endpointmarker; 

onclick of map

        @override public void onmapclick(latlng point) {     // todo auto-generated method stub     double lat = point.latitude;     double lng = point.longitude;      // add marker of destination point              try {                 geocoder geocoder;                 list<address> addresses;                 geocoder = new geocoder(bookcabscreen.this);                 if (lat != 0 || lng != 0) {                     addresses = geocoder.getfromlocation(lat, lng, 1);                     string address = addresses.get(0).getaddressline(0);                     string city = addresses.get(0).getaddressline(1);                     string country = addresses.get(0).getaddressline(2);                     log.d("tag", "address = " + address + ", city =" + city                             + ", country = " + country);                     endpointmarker = mmap.addmarker(new markeroptions()                             .position(new latlng(lat, lng))                             .title("location").snippet("" + address));                      markers.add(mmap.addmarker(new markeroptions()                             .position(new latlng(lat, lng))                             .title("location").snippet("" + address)));                     btnstartup.setenabled(true);                     btnstoppoint.setenabled(true);                      mjbbookcab.setendpointlat(lat);                     mjbbookcab.setendpointlng(lng);                 } else {                     toast.maketext(bookcabscreen.this,                             "latitude , longitude null",                             toast.length_long).show();                  }             } catch (exception e) {                 e.printstacktrace();              }   } 

on click of button

            if (endpointmarker != null) {             endpointmarker.remove();              endpointmarker = null;         } 

but not removing map ?please help

you adding same marker twice:

                endpointmarker = mmap.addmarker(new markeroptions()                         .position(new latlng(lat, lng))                         .title("location").snippet("" + address));                  markers.add(mmap.addmarker(new markeroptions()                         .position(new latlng(lat, lng))                         .title("location").snippet("" + address))); 

just remove 1 call googlemap.addmarker.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -