java - Android Google Maps - remove marker with icon -
i want remove marker on long click, , place in place without clearing whole map.
right circle radius works fine, custom pin icon not removed. using googlemap.clear() method should not used - there other objects on map don't want refreshed. have tried setposition method , had same result. how erase icon?
marker declaration:
marker = googlemap.addmarker(new markeroptions().position(marker.getposition()).draggable(true).title("info") .infowindowanchor(0.5f,0.5f).visible(false) .icon(bitmapdescriptorfactory.frombitmap(bitmapfactory.decoderesource(getresources(), r.drawable.pin_icon)))); this.googlemap.setonmaplongclicklistener(new googlemap.onmaplongclicklistener() { @override public void onmaplongclick(latlng latlng) { if (marker != null) { marker.remove(); } createmarker(latlng); } }); private void createmarker(latlng latlng) { marker = googlemap.addmarker(new markeroptions().position(latlng).draggable(true).title("info") .infowindowanchor(0.5f,0.5f) .icon(bitmapdescriptorfactory.frombitmap(bitmapfactory.decoderesource(getresources(), r.drawable.ic_pin_gr)))); }
i used such approach creating markers , setposition(new latlng(...))
working.
marker = mgooglemap.addmarker(new markeroptions() .anchor(0.5f, 0.5f) .icon(bitmapdescriptorfactory.fromresource(r.drawable.ic_pin)) .position(new latlng(cab.getlatitude(), cab.getlongitude())));
did try replace marker.remove();
on setposition()
inside onlongclick()
method ?
Comments
Post a Comment