Search in sources :

Example 1 with NearbyMarker

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));
            }
        }
    }
}
Also used : Bitmap(android.graphics.Bitmap) NearbyBaseMarker(fr.free.nrw.commons.nearby.NearbyBaseMarker) LatLng(com.mapbox.mapboxsdk.geometry.LatLng) Marker(com.mapbox.mapboxsdk.annotations.Marker) NearbyMarker(fr.free.nrw.commons.nearby.NearbyMarker) NearbyBaseMarker(fr.free.nrw.commons.nearby.NearbyBaseMarker) VectorDrawableCompat(androidx.vectordrawable.graphics.drawable.VectorDrawableCompat)

Example 2 with NearbyMarker

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);
}
Also used : NearbyMarker(fr.free.nrw.commons.nearby.NearbyMarker) Place(fr.free.nrw.commons.nearby.Place)

Aggregations

NearbyMarker (fr.free.nrw.commons.nearby.NearbyMarker)2 Bitmap (android.graphics.Bitmap)1 VectorDrawableCompat (androidx.vectordrawable.graphics.drawable.VectorDrawableCompat)1 Marker (com.mapbox.mapboxsdk.annotations.Marker)1 LatLng (com.mapbox.mapboxsdk.geometry.LatLng)1 NearbyBaseMarker (fr.free.nrw.commons.nearby.NearbyBaseMarker)1 Place (fr.free.nrw.commons.nearby.Place)1