use of com.mapbox.mapboxsdk.camera.CameraUpdate in project androidApp by InspectorIncognito.
the class RouterVectorMapFragment method zoomBound.
private void zoomBound(LatLng northEastPoint, LatLng southWestPoint) {
LatLngBounds.Builder latLngBoundsBuilder = new LatLngBounds.Builder();
latLngBoundsBuilder.include(northEastPoint);
latLngBoundsBuilder.include(southWestPoint);
CameraUpdate update = CameraUpdateFactory.newLatLngBounds(latLngBoundsBuilder.build(), 100, 100, 100, 100);
CameraPosition cameraPosition = update.getCameraPosition(mapboxMap);
if (cameraPosition == null) {
return;
}
mapboxMap.setCameraPosition(cameraPosition);
}
use of com.mapbox.mapboxsdk.camera.CameraUpdate in project osm-contributor by jawg.
the class MapFragment method changeMapZoomSmooth.
public void changeMapZoomSmooth(final double zoom, final OnZoomAnimationFinishedListener onZoomAnimationFinishedListener) {
mapboxMap.easeCamera(new CameraUpdate() {
@Override
public CameraPosition getCameraPosition(@NonNull MapboxMap mapboxMap) {
return new CameraPosition.Builder().target(mapboxMap.getCameraPosition().target).zoom(zoom).build();
}
}, 700);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
onZoomAnimationFinishedListener.onZoomAnimationFinished();
}
}, 750);
}
use of com.mapbox.mapboxsdk.camera.CameraUpdate in project androidApp by InspectorIncognito.
the class BusStopPlugin method onResponse.
private void onResponse(ArrayList<ServerSentBus> buses, ArrayList<ServerSentEvent> events, final BusStopLoadingLayerTask loaderTask, final Thread thread) {
buses = filterBuses(buses);
updateBusSource(buses);
for (ServerSentEvent event : events) {
event.finishInitialization();
}
((BusStopMarker) selectedBusStop).setEvents(events);
ArrayList<IconBuilder> buildingList = new ArrayList<>();
buildingList.add(new BusStopIconsBuilder(FeatureCollection.fromFeatures(new Feature[] { selectedBusStop })).toBuilder());
buildingList.add(new MapBusIconsBuilder(FeatureCollection.fromFeatures(busesFeatures.getFeatures())).toBuilder());
GenerateViewIconTask task = new GenerateViewIconTask(new GenerateViewIconTask.ImageLoaderListener() {
@Override
public void onImageGenResult(HashMap<String, View> viewMap, HashMap<String, Bitmap> bitmapHashMap) {
if (selectedBusStop == null) {
return;
}
Log.d(BusStopPlugin.class.getSimpleName(), "onImageGenResult");
if (mapboxMap != null) {
mapboxMap.addImages(bitmapHashMap);
} else {
return;
}
selectedBusStop.addBooleanProperty(BusStopMarker.PROPERTY_LOADING, false);
if (loaderTask != null && thread != null) {
loaderTask.stop();
thread.interrupt();
}
refreshBusStopSource();
refreshBusSource();
if (!busesFeatures.getFeatures().isEmpty()) {
Collections.sort(busesFeatures.getFeatures(), new Comparator<Feature>() {
@Override
public int compare(Feature bus1, Feature bus2) {
BusMarker m1 = (BusMarker) bus1;
BusMarker m2 = (BusMarker) bus2;
return m1.getBus().getDistanceToBusStop() < m2.getBus().getDistanceToBusStop() ? -1 : (m1.getBus().getDistanceToBusStop() == m2.getBus().getDistanceToBusStop() ? 0 : 1);
}
});
Feature busFeature = busesFeatures.getFeatures().get(0);
LatLngBounds.Builder latLngBoundsBuilder = new LatLngBounds.Builder();
latLngBoundsBuilder.include(MapboxUtil.convertToLatLng(busFeature));
latLngBoundsBuilder.include(MapboxUtil.getRotatePoint(busFeature, selectedBusStop, busFeature.getNumberProperty(BusMarker.PROPERTY_BEARING).doubleValue()));
CameraUpdate update = CameraUpdateFactory.newLatLngBounds(latLngBoundsBuilder.build(), 100, 100, 100, 100);
if (loaderTask != null && thread != null) {
MapboxUtil.animateCameraToNewCameraPosition(update.getCameraPosition(mapboxMap), mapboxMap);
// mapboxMap.animateCamera(update, 1000);
periodicRequestHandler.startPeriodicRequest();
final BusStop busStop = ((BusStopMarker) selectedBusStop).getBusStop();
listener.onBusStopSelected(busStop);
}
}
}
}, viewMap, buildingList);
((BusStopMarker) selectedBusStop).getBusStop().setIncomingBuses(buses);
task.execute();
}
use of com.mapbox.mapboxsdk.camera.CameraUpdate in project androidApp by InspectorIncognito.
the class VectorSearchMapFragment method zoomBound.
private void zoomBound(LatLng currentLocation) {
LatLngBounds.Builder latLngBoundsBuilder = new LatLngBounds.Builder();
latLngBoundsBuilder.includes(routeHelper.getRouteI());
latLngBoundsBuilder.include(currentLocation);
CameraUpdate update = CameraUpdateFactory.newLatLngBounds(latLngBoundsBuilder.build(), 100, 100, 100, 100);
CameraPosition cameraPosition = update.getCameraPosition(mapboxMap);
if (cameraPosition == null) {
return;
}
mapboxMap.setCameraPosition(cameraPosition);
}
Aggregations