use of com.mapbox.mapboxsdk.annotations.Marker in project apps-android-wikipedia by wikimedia.
the class NearbyFragment method initializeMap.
private void initializeMap() {
mapView.getMapAsync((@NonNull MapboxMap mapboxMap) -> {
if (!isAdded()) {
return;
}
NearbyFragment.this.mapboxMap = mapboxMap;
enableUserLocationMarker();
mapboxMap.getTrackingSettings().setMyLocationTrackingMode(MyLocationTracking.TRACKING_NONE);
mapboxMap.setOnScrollListener(this::fetchNearbyPages);
mapboxMap.setOnMarkerClickListener((@NonNull Marker marker) -> {
NearbyPage page = findNearbyPageFromMarker(marker);
if (page != null) {
PageTitle title = new PageTitle(page.getTitle(), lastResult.getWiki(), page.getThumbUrl());
onLoadPage(title, HistoryEntry.SOURCE_NEARBY, page.getLocation());
return true;
} else {
return false;
}
});
if (lastCameraPos != null) {
mapboxMap.setCameraPosition(lastCameraPos);
} else {
goToUserLocationOrPromptPermissions();
}
if (lastResult != null) {
showNearbyPages(lastResult);
}
});
}
Aggregations