use of fr.free.nrw.commons.nearby.NearbyMarker in project apps-android-commons by commons-app.
the class NearbyParentFragment method updateMarker.
/**
* Sets marker icon according to marker status. Sets title and distance.
* @param isBookmarked true if place is bookmarked
* @param place
* @param curLatLng current location
*/
public void updateMarker(final boolean isBookmarked, final Place place, @Nullable final fr.free.nrw.commons.location.LatLng curLatLng) {
VectorDrawableCompat vectorDrawable = VectorDrawableCompat.create(getContext().getResources(), getIconFor(place, isBookmarked), getContext().getTheme());
if (curLatLng != null) {
for (NearbyBaseMarker nearbyMarker : allMarkers) {
if (nearbyMarker.getMarker().getTitle() != null && nearbyMarker.getMarker().getTitle().equals(place.getName())) {
final Bitmap icon = UiUtils.getBitmap(vectorDrawable);
final String distance = formatDistanceBetween(curLatLng, place.location);
place.setDistance(distance);
final NearbyBaseMarker nearbyBaseMarker = new NearbyBaseMarker();
nearbyBaseMarker.title(place.name);
nearbyBaseMarker.position(new com.mapbox.mapboxsdk.geometry.LatLng(place.location.getLatitude(), place.location.getLongitude()));
nearbyBaseMarker.place(place);
nearbyBaseMarker.icon(IconFactory.getInstance(getContext()).fromBitmap(icon));
nearbyMarker.setIcon(IconFactory.getInstance(getContext()).fromBitmap(icon));
filteredMarkers.add(nearbyBaseMarker);
}
}
} else {
for (Marker marker : mapBox.getMarkers()) {
if (marker.getTitle() != null && marker.getTitle().equals(place.getName())) {
final Bitmap icon = UiUtils.getBitmap(vectorDrawable);
marker.setIcon(IconFactory.getInstance(getContext()).fromBitmap(icon));
}
}
}
}
use of fr.free.nrw.commons.nearby.NearbyMarker in project apps-android-commons by commons-app.
the class NearbyParentFragment method displayBottomSheetWithInfo.
@Override
public void displayBottomSheetWithInfo(final Marker marker) {
selectedMarker = marker;
final NearbyMarker nearbyMarker = (NearbyMarker) marker;
final Place place = nearbyMarker.getNearbyBaseMarker().getPlace();
passInfoToSheet(place);
hideBottomSheet();
bottomSheetDetailsBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
}
Aggregations