private void perform(MarkerModifier markerModifier) { // Don't show small clusters. Render the markers inside, instead. if (!shouldRenderAsCluster(cluster)) { for (T item : cluster.getItems()) { Marker marker = mMarkerCache.get(item); MarkerWithPosition markerWithPosition; if (marker == null) { MarkerOptions markerOptions = new MarkerOptions(); if (animateFrom != null) { markerOptions.position(animateFrom); markerOptions.icon(item.getBitmapDescriptor()); } else { markerOptions.position(item.getPosition()); markerOptions.icon(item.getBitmapDescriptor()); } onBeforeClusterItemRendered(item, markerOptions); marker = mClusterManager.getMarkerCollection().addMarker(markerOptions); markerWithPosition = new MarkerWithPosition(marker); mMarkerCache.put(item, marker); if (animateFrom != null) { markerModifier.animate(markerWithPosition, animateFrom, item.getPosition()); } } else { markerWithPosition = new MarkerWithPosition(marker); } onClusterItemRendered(item, marker); newMarkers.add(markerWithPosition); } return; } MarkerOptions markerOptions = new MarkerOptions().position(animateFrom == null ? cluster.getPosition() : animateFrom); onBeforeClusterRendered(cluster, markerOptions); Marker marker = mClusterManager.getClusterMarkerCollection().addMarker(markerOptions); mMarkerToCluster.put(marker, cluster); mClusterToMarker.put(cluster, marker); MarkerWithPosition markerWithPosition = new MarkerWithPosition(marker); if (animateFrom != null) { markerModifier.animate(markerWithPosition, animateFrom, cluster.getPosition()); } onClusterRendered(cluster, marker); newMarkers.add(markerWithPosition); }
@Override public void onRelation(final EntityLocation entityLocation, final boolean auto) { if (mWaitfor != null) { mWaitfor.close(); mWaitfor = null; } if (!auto) { int id = R.string.request_relation_success; if (entityLocation == null) id = R.string.request_relation_fail; final Toast toast = Toast.makeText(this, id, Toast.LENGTH_LONG); toast.show(); } if (mHandler == null) mHandler = new Handler(); final int delayed = 2 * 60 * 1000; mHandler.postDelayed(this, delayed); if (mEntityRelation == null || entityLocation == null) { mapViewRefresh(mLatitude, mLongitude, mZoom); return; } final String to = mEntityRelation.getTo(); if (to == null) { mapViewRefresh(mLatitude, mLongitude, mZoom); return; } final String sColor = entityLocation.getColor(); final List<EntityLocations> locations = entityLocation.getLocations(); if (locations == null) { mapViewRefresh(mLatitude, mLongitude, mZoom); return; } int color = 0, alpha = 20; try { color = Color.parseColor(sColor); } catch (Exception e) { color = Color.argb(alpha, 255, 0, 0); } color = Color.argb(alpha, Color.red(color), Color.green(color), Color.blue(color)); if (locations.size() > 0) { mBaiduMap.clear(); int i = 0; for (final EntityLocations entityLocations : locations) { addTime(sColor, entityLocations, i); final int j = i + 1; final String name = to.toLowerCase(Locale.ENGLISH) + j; final double latitude = entityLocations.getLatitude(); final double longitude = entityLocations.getLongitude(); final double accuracy = entityLocations.getRadius(); if (i == 0) { mLatitude = latitude; mLongitude = longitude; } final MarkerOptions markerOptions = new MarkerOptions(); final CircleOptions circleOptions = new CircleOptions(); final LatLng latLng = new LatLng(latitude, longitude); markerOptions.position(latLng); circleOptions.center(latLng); circleOptions.radius((int) accuracy); circleOptions.fillColor(color); circleOptions.stroke(new Stroke(1, color)); if (mBitmapDescriptor.containsKey(name)) { final BitmapDescriptor bitmapDescriptor = mBitmapDescriptor.get(name); markerOptions.icon(bitmapDescriptor); mBaiduMap.addOverlay(markerOptions); } else { final BitmapDescriptor bitmapDescriptor = Images.getIcon(name); if (bitmapDescriptor != null) { markerOptions.icon(bitmapDescriptor); mBitmapDescriptor.put(name, bitmapDescriptor); mBaiduMap.addOverlay(markerOptions); } } mBaiduMap.addOverlay(circleOptions); i++; } mapViewRefresh(mLatitude, mLongitude, 17.0f, 800); } }