Reputation: 601
For some reason I'm noticing that the markers that I download the icon for don't stick in their lon/lat when I zoom in and out. However, if I use assets that are in the project it doesn't happen. Does anyone know why?
I'm loading the assets using:
Picasso.with(mActivity).load(strUrl).into(currentMarker.getCurrentMarker());
--EDIT --
public class CustomMarker implements Target {
Marker mMarker;
private boolean doneLoad;
public CustomMarker(Marker marker) {
mMarker = marker;
doneLoad = false;
}
@Override
public int hashCode() {
return mMarker.hashCode();
}
@Override
public boolean equals(Object o) {
if(o instanceof CustomMarker) {
Marker marker = ((CustomMarker) o).mMarker;
return mMarker.equals(marker);
} else {
return false;
}
}
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) throws IllegalArgumentException {
if (doneLoad == false) {
try {
mMarker.setIcon(BitmapDescriptorFactory.fromBitmap(bitmap));
doneLoad = true;
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
}
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
public Marker getmMarker() {
return mMarker;
}
public boolean isDoneLoad() {
return doneLoad;
}
public void setDoneLoad(boolean doneLoad) {
this.doneLoad = doneLoad;
}
}
Upvotes: 0
Views: 116
Reputation: 18262
The problem is that the icon is incorrectly anchored.
Add this after setIcon
on your CustomMarker.onBitmapLoaded
:
mMarker.setAnchor(0.5f,1f);
Upvotes: 1