use of org.osmdroid.DefaultResourceProxyImpl in project open-event-android by fossasia.
the class OSMapFragment method populateMap.
private void populateMap() {
if (!mayRequestStorageForOfflineMap())
return;
final MapView mapView = (MapView) rootView.findViewById(R.id.mapview);
final ZoomControls zoomControls = (ZoomControls) rootView.findViewById(R.id.zoomControls);
Resources resources = getContext().getResources();
int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
if (resourceId > 0) {
zoomControls.setPadding(0, 0, 0, resources.getDimensionPixelSize(resourceId) + 4);
}
mapView.setBuiltInZoomControls(false);
mapView.setMultiTouchControls(true);
event = realmRepo.getEvent();
event.addChangeListener(new RealmChangeListener<RealmModel>() {
@Override
public void onChange(RealmModel realmModel) {
showEvent();
}
});
GeoPoint geoPoint = new GeoPoint(getDestinationLatitude(), getDestinationLongitude());
mapView.getController().setCenter(geoPoint);
mapView.getController().setZoom(17);
mapView.setMaxZoomLevel(20);
mapView.setMinZoomLevel(3);
OverlayItem position = new OverlayItem(getDestinationName(), "Location", geoPoint);
zoomControls.setOnZoomInClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mapView.getController().zoomIn();
}
});
zoomControls.setOnZoomOutClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mapView.getController().zoomOut();
}
});
ArrayList<OverlayItem> items = new ArrayList<>();
items.add(position);
mapView.getOverlays().add(new ItemizedIconOverlay<>(items, new ItemizedIconOverlay.OnItemGestureListener<OverlayItem>() {
@Override
public boolean onItemSingleTapUp(int index, OverlayItem item) {
return false;
}
@Override
public boolean onItemLongPress(int index, OverlayItem item) {
return false;
}
}, new DefaultResourceProxyImpl(getActivity())));
mapView.invalidate();
}
Aggregations