use of com.mapbox.mapboxsdk.geometry.LatLngBounds in project mapbox-plugins-android by mapbox.
the class RegionSelectionFragment method createRegion.
OfflineTilePyramidRegionDefinition createRegion() {
if (mapboxMap == null) {
throw new NullPointerException("MapboxMap is null and can't be used to create Offline region" + "definition.");
}
RectF rectF = getSelectionRegion();
LatLng northEast = mapboxMap.getProjection().fromScreenLocation(new PointF(rectF.right, rectF.top));
LatLng southWest = mapboxMap.getProjection().fromScreenLocation(new PointF(rectF.left, rectF.bottom));
LatLngBounds bounds = new LatLngBounds.Builder().include(northEast).include(southWest).build();
double cameraZoom = mapboxMap.getCameraPosition().zoom;
float pixelRatio = getActivity().getResources().getDisplayMetrics().density;
return new OfflineTilePyramidRegionDefinition(mapboxMap.getStyleUrl(), bounds, cameraZoom - 2, cameraZoom + 2, pixelRatio);
}
use of com.mapbox.mapboxsdk.geometry.LatLngBounds in project mapbox-plugins-android by mapbox.
the class LocalizationPlugin method setCameraToLocaleCountry.
/**
* You can pass in a {@link MapLocale} directly into this method which uses the country bounds
* defined in it to represent the language found on the map.
*
* @param mapLocale he {@link MapLocale} object which contains the desired map bounds
* @throws NullPointerException thrown when it was expecting a {@link LatLngBounds} but instead
* it was null
* @since 0.1.0
*/
public void setCameraToLocaleCountry(MapLocale mapLocale) {
LatLngBounds bounds = mapLocale.getCountryBounds();
if (bounds == null) {
throw new NullPointerException("Expected a LatLngBounds object but received null instead. Mak" + "e sure your MapLocale instance also has a country bounding box defined.");
}
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 50));
}
use of com.mapbox.mapboxsdk.geometry.LatLngBounds in project osm-contributor by jawg.
the class MapFragmentPresenter method loadPoi.
private void loadPoi(boolean refreshData, boolean forceRefresh) {
if (poiTypes == null) {
Timber.v("PleaseLoadPoiTypes");
eventBus.post(new PleaseLoadPoiTypes());
}
LatLngBounds viewLatLngBounds = mapFragment.getViewLatLngBounds();
if (viewLatLngBounds != null) {
if (mapFragment.getZoomLevel() > BuildConfig.ZOOM_MARKER_MIN) {
if (shouldReload(viewLatLngBounds) || refreshData || forceRefresh) {
previousZoom = mapFragment.getZoomLevel();
triggerReloadPoiLatLngBounds = LatLngBoundsUtils.enlarge(viewLatLngBounds, 1.2);
LatLngBounds latLngToLoad = LatLngBoundsUtils.enlarge(viewLatLngBounds, 1.2);
getPoisAndNotes.unsubscribe();
Timber.e("Unsubscribe current loading");
if (getPoisSubscriber != null) {
getPoisSubscriber.unsubscribe();
}
getPoisSubscriber = new GetPoisSubscriber();
getPoisAndNotes.init(Box.convertFromLatLngBounds(latLngToLoad), refreshData).execute(getPoisSubscriber);
mapFragment.displayZoomTooLargeError(false);
}
} else {
forceRefreshPoi = true;
cleanAllZoomTooLarge();
}
}
}
use of com.mapbox.mapboxsdk.geometry.LatLngBounds in project osm-contributor by jawg.
the class LatLngBoundsUtils method enlarge.
public static LatLngBounds enlarge(LatLngBounds viewLatLngBounds, double factor) {
double n = viewLatLngBounds.getLatNorth();
double e = viewLatLngBounds.getLonEast();
double s = viewLatLngBounds.getLatSouth();
double w = viewLatLngBounds.getLonWest();
double f = (factor - 1) / 2;
return new LatLngBounds.Builder().include(new LatLng(n + f * (n - s), e + f * (e - w))).include(new LatLng(s - f * (n - s), w - f * (e - w))).build();
}
use of com.mapbox.mapboxsdk.geometry.LatLngBounds in project osm-contributor by jawg.
the class Box method enlarge.
/**
* Enlarge the Box.
*
* @param viewLatLngBounds The box to enlarge.
* @param factor The factor to enlarge the box.
* @return Box the Box enlarged.
*/
public static LatLngBounds enlarge(LatLngBounds viewLatLngBounds, double factor) {
double n = viewLatLngBounds.getLatNorth();
double e = viewLatLngBounds.getLonEast();
double s = viewLatLngBounds.getLatSouth();
double w = viewLatLngBounds.getLonWest();
double f = (factor - 1) / 2;
return new LatLngBounds.Builder().include(new LatLng(n + f * (n - s), e + f * (e - w))).include(new LatLng(s - f * (n - s), w - f * (e - w))).build();
}
Aggregations