I want to change selected marker icon on Google Maps, so I have following code:
googleMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker) {
if (null != currentMarker) {
currentMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.ic_arrowautougasen));
}
currentMarker = marker;
currentMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.ic_autoselektovan));
return true;
}
});
googleMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
@Override
public void onMapClick(LatLng latLng) {
if(null != currentMarker) {
currentMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.ic_arrowautougasen));
}
currentMarker = null;
}
});
On this line I get error from below:
if(null != currentMarker) {
currentMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.ic_arrowautougasen));
}
Here is the exception:
java.lang.IllegalArgumentException: Unmanaged descriptor
at com.google.maps.api.android.lib6.common.k.b(:com.google.android.gms.DynamiteModulesB:162)
at com.google.maps.api.android.lib6.impl.o.c(:com.google.android.gms.DynamiteModulesB:75)
at com.google.maps.api.android.lib6.impl.db.a(:com.google.android.gms.DynamiteModulesB:334)
at com.google.android.gms.maps.model.internal.q.onTransact(:com.google.android.gms.DynamiteModulesB:204)
at android.os.Binder.transact(Binder.java:387)
at com.google.android.gms.maps.model.internal.zzf$zza$zza.zzL(Unknown Source)
at com.google.android.gms.maps.model.Marker.setIcon(Unknown Source)
at ba.kordinata.kogps.live.map.MapFragment$5.onMapClick(MapFragment.java:212)