-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue refreshing markers #63
Comments
I think this is because this callback happens prior to a cluster item map marker being added to the map object. So you only get to override the icon once, right when the marker is created for the first time. To get the item to update you'd have to remove it and add it back, I think. I did something different, I manually overrode the callback for the cluster manager's marker items: clusterManager.getMarkerCollection().setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker) {
BitmapDescriptor icon = ...;
marker.setIcon(icon);
}
} Although I am currently debugging some issues with this approach, where when that marker whose icon has been set with setIcon gets removed from the map (via |
@jakeonrails @daschewie may be related #90 |
This is also my use case. Any stable way to achieve this? |
This commit makes it possible: 49d42d6 |
@jakeonrails You can theoretically override So what I think we really want is for |
java.lang.IllegalArgumentException: Released unknown imageData reference Getting above error while using onClusterItemRendered. I am running async task to get image for marker: protected void onClusterItemRendered(Poi clusterItem, Marker marker) {
super.onClusterItemRendered(clusterItem, marker);
try {
URL url = new URL(clusterItem.getImage());
AsyncDownloadImage async = new AsyncDownloadImage(marker);
async.execute(url);
} catch (MalformedURLException e) {
Log.e("CluserRenderer", "Wrong url address: " + clusterItem.getImage());
}
} And in onPostExecute I do this (markerReference is WeakReference): protected void onPostExecute(final Bitmap bitmap) {
Marker marker = markerReference.get();
if (bitmap != null && marker != null) {
mImageView.setImageBitmap(bitmap);
Bitmap icon = mIconGenerator.makeIcon();
try {
marker.setIcon(BitmapDescriptorFactory.fromBitmap(icon));
} catch (IllegalArgumentException e) {
Log.e("ClusterRenderer", "Couldn't set icon.");
}
}
} Images for marker cluster items do render while zooming in, then while zooming out the cluster group is rendered for marker, then again while zooming in items do render correctly. Exception occurs when user do zoom in and zoom out fast when items did not render yet. |
Keeping marker object instead of weakreference in async fixed issue for me. Additionaly I keep hashmap of already downloaded url/ bitmap in ClusterRenderer class. Whenever clusteritem gets rendered it checks hashmap for bitmaps. |
Nope, still crashes, same error as before. |
@darekdeo +1 |
Currently working on same issue hopefully can figure something out. |
I managed to get this working for showing a selected state on a marker. It requires extending the DefaultClusterRenderer class and overriding one method (onBeforeClusterItemRendered) and adding an onClusterItemClick listener.
|
getMarker() always returns null for me, no way to get this working... |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. Please comment here if it is still valid so that we can reprioritize. Thank you! |
Duplicate of #90, closing this issue in favor of that one instead. See the discussion there for possible workarounds in the meantime. |
I am trying to change the icon for a selected marker. Neither calling ClusterManager.cluster, nor MapView.invalidate will cause the ClusterRenderer to render new pins.
The text was updated successfully, but these errors were encountered: