Skip to content

Instantly share code, notes, and snippets.

@mousebird
Created October 13, 2016 17:58
Show Gist options
  • Save mousebird/4705d48643956c94996147052a615be3 to your computer and use it in GitHub Desktop.
Save mousebird/4705d48643956c94996147052a615be3 to your computer and use it in GitHub Desktop.
// Add a marker for each point in a list of vectors
private void insertClusteredMarkers(List<VectorObject> vectors, MaplyBaseController inController)
{
// The markers will be 32x32 pixels
Point2d size = new Point2d(32, 32);
List<ScreenMarker> markers = new ArrayList<>();
Bitmap icon = BitmapFactory.decodeResource(getActivity().getResources(), R.drawable.sticker);
// For each vector object, add a marker in the middle
for (VectorObject v : vectors) {
ScreenMarker marker = new ScreenMarker();
marker.image = icon;
marker.loc = v.centroid();
marker.size = size;
marker.selectable = true;
if (marker.loc != null)
markers.add(marker);
}
// Invoke the layout engine and ask the markers to cluster
MarkerInfo info = new MarkerInfo();
info.setLayoutImportance(1.f);
info.setClusterGroup(0);
// Add all the markers at once
inController.addScreenMarkers(markers, info, MaplyBaseController.ThreadMode.ThreadCurrent);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment