use of com.mapbox.mapboxsdk.annotations.Icon in project mapbox-plugins-android by mapbox.
the class DefaultClusterRenderer method onBeforeClusterRendered.
/**
* Called before the marker for a Cluster is added to the map.
* The default implementation draws a circle with a rough count of the number of items.
*/
protected void onBeforeClusterRendered(Cluster<T> cluster, MarkerOptions markerOptions) {
int bucket = getBucket(cluster);
Icon descriptor = mIcons.get(bucket);
if (descriptor == null) {
mColoredCircleBackground.getPaint().setColor(getColor(bucket));
descriptor = IconFactory.getInstance(Mapbox.getApplicationContext()).fromBitmap(mIconGenerator.makeIcon(getClusterText(bucket)));
mIcons.put(bucket, descriptor);
}
markerOptions.icon(descriptor);
}
use of com.mapbox.mapboxsdk.annotations.Icon in project apps-android-commons by commons-app.
the class NearbyParentFragment method addCurrentLocationMarker.
/**
* Adds a marker for the user's current position. Adds a
* circle which uses the accuracy * 2, to draw a circle
* which represents the user's position with an accuracy
* of 95%.
*
* Should be called only on creation of mapboxMap, there
* is other method to update markers location with users
* move.
* @param curLatLng current location
*/
@Override
public void addCurrentLocationMarker(final fr.free.nrw.commons.location.LatLng curLatLng) {
if (null != curLatLng && !isPermissionDenied && locationManager.isGPSProviderEnabled()) {
ExecutorUtils.get().submit(() -> {
mapView.post(() -> removeCurrentLocationMarker());
Timber.d("Adds current location marker");
final Icon icon = IconFactory.getInstance(getContext()).fromResource(R.drawable.current_location_marker);
final MarkerOptions currentLocationMarkerOptions = new MarkerOptions().position(new LatLng(curLatLng.getLatitude(), curLatLng.getLongitude()));
// Set custom icon
currentLocationMarkerOptions.setIcon(icon);
mapView.post(() -> currentLocationMarker = mapBox.addMarker(currentLocationMarkerOptions));
final List<LatLng> circle = UiUtils.createCircleArray(curLatLng.getLatitude(), curLatLng.getLongitude(), curLatLng.getAccuracy() * 2, 100);
final PolygonOptions currentLocationPolygonOptions = new PolygonOptions().addAll(circle).strokeColor(getResources().getColor(R.color.current_marker_stroke)).fillColor(getResources().getColor(R.color.current_marker_fill));
mapView.post(() -> currentLocationPolygon = mapBox.addPolygon(currentLocationPolygonOptions));
});
} else {
Timber.d("not adding current location marker..current location is null");
}
}
Aggregations