本文整理汇总了Java中com.mapbox.mapboxsdk.geometry.BoundingBox类的典型用法代码示例。如果您正苦于以下问题:Java BoundingBox类的具体用法?Java BoundingBox怎么用?Java BoundingBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BoundingBox类属于com.mapbox.mapboxsdk.geometry包,在下文中一共展示了BoundingBox类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onCreate
import com.mapbox.mapboxsdk.geometry.BoundingBox; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = this.getIntent();
String fileName = intent.getStringExtra(Intent.EXTRA_TEXT);
MapView mapView = new MapView(this);
BoundingBox box;
TileLayer mbTileLayer = new MBTilesLayer(this, fileName);
mapView.setTileSource(new ITileLayer[] {
mbTileLayer, new WebSourceTileLayer("mapquest",
"http://otile1.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png").setName(
"MapQuest Open Aerial")
.setAttribution("Tiles courtesy of MapQuest and OpenStreetMap contributors.")
.setMinimumZoomLevel(1)
.setMaximumZoomLevel(18)
});
box = mbTileLayer.getBoundingBox();
mapView.setScrollableAreaLimit(box);
mapView.setMinZoomLevel(mapView.getTileProvider().getMinimumZoomLevel());
mapView.setMaxZoomLevel(mapView.getTileProvider().getMaximumZoomLevel());
mapView.setCenter(mapView.getTileProvider().getCenterCoordinate());
mapView.setZoom(0);
Log.d("MapboxPlugin", "zoomToBoundingBox " + box.toString());
setContentView(mapView);
}
开发者ID:affinitybridge,项目名称:cordova-mapbox-android-sdk,代码行数:31,代码来源:OfflineMapActivity.java
示例2: minimumZoomForBoundingBox
import com.mapbox.mapboxsdk.geometry.BoundingBox; //导入依赖的package包/类
/**
* compute the minimum zoom necessary to show a BoundingBox
*
* @param boundingBox the box to compute the zoom for
* @param regionFit if true computed zoom will make sure the whole box is visible
* @param roundedZoom if true the required zoom will be rounded (for better
* graphics)
* @return the minimum zoom necessary to show the bounding box
*/
private double minimumZoomForBoundingBox(final BoundingBox boundingBox,
final boolean regionFit, final boolean roundedZoom) {
final RectF rect = Projection.toMapPixels(boundingBox,
TileLayerConstants.MAXIMUM_ZOOMLEVEL, mTempRect);
final float requiredLatitudeZoom = TileLayerConstants.MAXIMUM_ZOOMLEVEL
- (float) ((Math.log(rect.height() / getMeasuredHeight()) / Math
.log(2)));
final float requiredLongitudeZoom = TileLayerConstants.MAXIMUM_ZOOMLEVEL
- (float) ((Math.log(rect.width() / getMeasuredWidth()) / Math
.log(2)));
double result = regionFit ? Math.min(requiredLatitudeZoom,
requiredLongitudeZoom) : Math.max(requiredLatitudeZoom,
requiredLongitudeZoom);
if (roundedZoom) {
result = regionFit ? Math.floor(result) : Math.round(result);
}
return result;
}
开发者ID:RoProducts,项目名称:rastertheque,代码行数:28,代码来源:MapView.java
示例3: initTrackPath
import com.mapbox.mapboxsdk.geometry.BoundingBox; //导入依赖的package包/类
/**
* @param track
*/
private void initTrackPath(Track track) {
// Configure the line representation.
Paint linePaint = new Paint();
linePaint.setStyle(Paint.Style.STROKE);
linePaint.setColor(Color.BLUE);
linePaint.setStrokeWidth(5);
TrackSpeedMapOverlay trackMapOverlay = new TrackSpeedMapOverlay(track);
trackMapOverlay.setPaint(linePaint);
// Adds the path overlay to the mapview.
mMapView.getOverlays().add(trackMapOverlay);
final BoundingBox viewBbox = trackMapOverlay.getViewBoundingBox();
final BoundingBox scrollableLimit = trackMapOverlay.getScrollableLimitBox();
mMapView.setScrollableAreaLimit(scrollableLimit);
mMapView.setConstraintRegionFit(true);
mMapView.zoomToBoundingBox(viewBbox, true);
}
开发者ID:enviroCar,项目名称:enviroCar-app,代码行数:25,代码来源:TrackDetailsActivity.java
示例4: createMapboxMap
import com.mapbox.mapboxsdk.geometry.BoundingBox; //导入依赖的package包/类
private void createMapboxMap(final String mapId) {
this.cordova.getActivity().runOnUiThread(new Runnable() {
public void run() {
Activity activity = cordova.getActivity();
MapView mapView = new MapView(webView.getContext());
BoundingBox box;
// Get Mapbox access token from Android's application resources.
Resources res = activity.getResources();
int resId = res.getIdentifier("mapboxAccessToken", "string", activity.getPackageName());
String accessToken = res.getString(resId);
// Mapbox tile layer.
mapView.setAccessToken(accessToken);
TileLayer mbTileLayer = new MapboxTileLayer(mapId);
mapView.setTileSource(mbTileLayer);
// END Mapbox tile layer.
box = mbTileLayer.getBoundingBox();
mapView.setScrollableAreaLimit(box);
mapView.setMinZoomLevel(mapView.getTileProvider().getMinimumZoomLevel());
mapView.setMaxZoomLevel(mapView.getTileProvider().getMaximumZoomLevel());
mapView.setCenter(mapView.getTileProvider().getCenterCoordinate());
mapView.setZoom(0);
Log.d("MapboxPlugin", "zoomToBoundingBox " + box.toString());
activity.setContentView(mapView);
}
});
}
开发者ID:affinitybridge,项目名称:cordova-mapbox-android-sdk,代码行数:31,代码来源:Mapbox.java
示例5: onCreate
import com.mapbox.mapboxsdk.geometry.BoundingBox; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(this.resource("layout", "map_editor"));
MapView mapView = this.mapView = (MapView) this.findViewById(this.resource("id", "mapeditor"));
Intent intent = this.getIntent();
this.initFeatureBuilder(mapView);
this.initGeometryTypeLimits(intent);
this.initAddMenuButtons();
this.initBaseLayer(intent, mapView);
ArrayList<LatLng> latLngs = new ArrayList<LatLng>();
if (intent.hasExtra(Mapbox.EXTRA_GEOJSON)) {
GeoJSONObject geojson = intent.getParcelableExtra(Mapbox.EXTRA_GEOJSON);
this.parseGeoJSON(geojson, latLngs);
BoundingBox featuresExtent = GeoUtils.findBoundingBoxForGivenLocations(latLngs, 1.0);
Log.d("MapEditorActivity", String.format("Number of latlngs: %d", latLngs.size()));
if (MapEditorActivity.pointsWithinBox(this.mapExtent, latLngs)) {
Log.d("MapEditorActivity", String.format("Zooming to Features extent: %s", featuresExtent));
mapView.zoomToBoundingBox(featuresExtent);
mapView.setCenter(featuresExtent.getCenter());
} else if (latLngs.size() > 0) {
CharSequence message = "Some features are outside of the available map area.";
Toast toast = Toast.makeText(this.getBaseContext(), message, Toast.LENGTH_LONG);
toast.show();
Log.d("MapEditorActivity", message.toString());
}
}
if (latLngs.isEmpty()) {
Log.d("MapEditorActivity", "No GeoJSON, zooming to user location.");
this.toggleUserLocation(true);
}
}
开发者ID:affinitybridge,项目名称:cordova-mapbox-android-sdk,代码行数:39,代码来源:MapEditorActivity.java
示例6: replaceWithMBTiles
import com.mapbox.mapboxsdk.geometry.BoundingBox; //导入依赖的package包/类
/**
* MapBox provides is "own" MBTiles driver, no need to use rastertheque
* @param filePath
*/
private void replaceWithMBTiles(final String filePath) {
mCurrentLayer = new MBTilesLayer(new File(filePath));
mv.setTileSource(mCurrentLayer);
BoundingBox box = mCurrentLayer.getBoundingBox();
mv.setScrollableAreaLimit(box);
mv.setMinZoomLevel(mv.getTileProvider().getMinimumZoomLevel());
mv.setMaxZoomLevel(mv.getTileProvider().getMaximumZoomLevel());
currentMap = filePath;
}
开发者ID:RoProducts,项目名称:rastertheque,代码行数:17,代码来源:MapBoxSampleActivity.java
示例7: initialize
import com.mapbox.mapboxsdk.geometry.BoundingBox; //导入依赖的package包/类
/**
* initializes this layer by setting up the initial zoom, internal scale and the boundingbox
*/
private void initialize() {
this.mTileSize = getTileSizePixels();
final Envelope bb = GDALDataset.convertToLatLon(mRasterDataset.getBoundingBox(),Proj.proj2wkt(mRasterDataset.getCRS().getParameterString()));
final LatLng sw = new LatLng(bb.getMinY(),bb.getMinX());
final LatLng ne = new LatLng(bb.getMaxY(),bb.getMaxX());
final Rect dim = mRasterDataset.getDimension();
final int width = dim.width();
final int height = dim.height();
//meters per pixel of this raster --> distance min-max / length min-max
double res_in_Meters = Formulae.distanceBetweenInMeters(bb.getMinY(),bb.getMinX(), bb.getMaxY(),bb.getMaxX()) /
Math.hypot(height,width);
int startZoomLevel = 0;
while(Formulae.getResolutionInMetersPerPixelForZoomLevel(startZoomLevel) > res_in_Meters){
startZoomLevel++;
}
Log.d(TAG, "calculated start zoom level "+ startZoomLevel);
mMinimumZoomLevel = Math.max(0, startZoomLevel - 5);
mStartZoomLevel = startZoomLevel;
mMaximumZoomLevel = Math.min(18, startZoomLevel + 8);
mName = mRasterDataset.getSource();
mDescription = "GDALLayer";
mBoundingBox = new BoundingBox(ne, sw);
mCenter = mBoundingBox.getCenter();
mStart = System.currentTimeMillis();
}
开发者ID:RoProducts,项目名称:rastertheque,代码行数:41,代码来源:GDALTileLayer.java
示例8: getBoundingBoxInternal
import com.mapbox.mapboxsdk.geometry.BoundingBox; //导入依赖的package包/类
public BoundingBox getBoundingBoxInternal() {
if (getMeasuredWidth() == 0 || getMeasuredHeight() == 0) {
return null;
}
final Rect screenRect = GeometryMath.viewPortRect(getProjection(), null);
ILatLng neGeoPoint =
Projection.pixelXYToLatLong(screenRect.right, screenRect.top, mZoomLevel);
ILatLng swGeoPoint =
Projection.pixelXYToLatLong(screenRect.left, screenRect.bottom, mZoomLevel);
return new BoundingBox(neGeoPoint.getLatitude(), neGeoPoint.getLongitude(),
swGeoPoint.getLatitude(), swGeoPoint.getLongitude());
}
开发者ID:RoProducts,项目名称:rastertheque,代码行数:14,代码来源:MapView.java
示例9: zoomToBoundingBox
import com.mapbox.mapboxsdk.geometry.BoundingBox; //导入依赖的package包/类
/**
* Zoom the map to enclose the specified bounding box, as closely as
* possible.
*
* @param boundingBox the box to compute the zoom for
* @param regionFit if true computed zoom will make sure the whole box is visible
* @param animated if true the zoom will be animated
* @param roundedZoom if true the required zoom will be rounded (for better
* graphics)
* @param userAction set to true if it comes from a userAction
* @return the map view, for chaining
*/
public MapView zoomToBoundingBox(final BoundingBox boundingBox,
final boolean regionFit, final boolean animated,
final boolean roundedZoom, final boolean userAction) {
BoundingBox inter = (mScrollableAreaBoundingBox != null) ? mScrollableAreaBoundingBox
.intersect(boundingBox) : boundingBox;
if (inter == null || !inter.isValid()) {
return this;
}
if (!mLayedOut) {
mBoundingBoxToZoomOn = inter;
mBoundingBoxToZoomOnRegionFit = regionFit;
return this;
}
// Zoom to boundingBox center, at calculated maximum allowed zoom level
final LatLng center = inter.getCenter();
final float zoom = (float) minimumZoomForBoundingBox(inter, regionFit,
roundedZoom);
if (animated) {
getController().setZoomAnimated(zoom, center, true, userAction);
} else {
getController().setZoom(zoom, center, userAction);
}
return this;
}
开发者ID:RoProducts,项目名称:rastertheque,代码行数:39,代码来源:MapView.java
示例10: setScrollableAreaLimit
import com.mapbox.mapboxsdk.geometry.BoundingBox; //导入依赖的package包/类
/**
* Set the map to limit it's scrollable view to the specified BoundingBox. Note this does not
* limit zooming so it will be possible for the user to zoom to an area that is larger than the
* limited area.
*
* @param boundingBox A lat/long bounding box to limit scrolling to, or null to remove any
* scrolling
* limitations
*/
public void setScrollableAreaLimit(BoundingBox boundingBox) {
mScrollableAreaBoundingBox = boundingBox;
// Clear scrollable area limit if null passed.
if (mScrollableAreaBoundingBox == null) {
mMinimumZoomLevel = mRequestedMinimumZoomLevel;
mScrollableAreaLimit = null;
} else {
updateScrollableAreaLimit();
updateMinZoomLevel();
}
}
开发者ID:RoProducts,项目名称:rastertheque,代码行数:23,代码来源:MapView.java
示例11: toMapPixels
import com.mapbox.mapboxsdk.geometry.BoundingBox; //导入依赖的package包/类
public static RectF toMapPixels(final BoundingBox box, final float zoom, final RectF reuse) {
final RectF out;
if (reuse != null) {
out = reuse;
} else {
out = new RectF();
}
final int mapSize_2 = mapSize(zoom) >> 1;
PointF nw = latLongToPixelXY(box.getLatNorth(), box.getLonWest(), zoom, null);
PointF se = latLongToPixelXY(box.getLatSouth(), box.getLonEast(), zoom, null);
out.set(nw.x, nw.y, se.x, se.y);
out.offset(-mapSize_2, -mapSize_2);
return out;
}
开发者ID:RoProducts,项目名称:rastertheque,代码行数:15,代码来源:Projection.java
示例12: getBounds
import com.mapbox.mapboxsdk.geometry.BoundingBox; //导入依赖的package包/类
public BoundingBox getBounds() {
String result = getStringValue("bounds");
if (result != null) {
String[] boundsArray = result.split(",\\s*");
return new BoundingBox(Double.parseDouble(boundsArray[3]),
Double.parseDouble(boundsArray[2]), Double.parseDouble(boundsArray[1]),
Double.parseDouble(boundsArray[0]));
}
return null;
}
开发者ID:RoProducts,项目名称:rastertheque,代码行数:11,代码来源:MBTilesFileArchive.java
示例13: getBoundingBox
import com.mapbox.mapboxsdk.geometry.BoundingBox; //导入依赖的package包/类
@Override
public BoundingBox getBoundingBox() {
BoundingBox result = null;
synchronized (mTileProviderList) {
for (final MapTileModuleLayerBase tileProvider : mTileProviderList) {
BoundingBox providerBox = tileProvider.getBoundingBox();
if (result == null) {
result = providerBox;
} else {
result = result.union(providerBox);
}
}
}
return result;
}
开发者ID:RoProducts,项目名称:rastertheque,代码行数:16,代码来源:MapTileLayerArray.java
示例14: initWithTileJSON
import com.mapbox.mapboxsdk.geometry.BoundingBox; //导入依赖的package包/类
private void initWithTileJSON(JSONObject aTileJSON) {
this.setTileJSON((aTileJSON != null) ? aTileJSON : new JSONObject());
if (aTileJSON != null) {
if (this.tileJSON.has("tiles")) {
try {
this.setURL(this.tileJSON.getJSONArray("tiles")
.getString(0)
.replace(".png", "{2x}.png"));
} catch (JSONException e) {
Log.e(TAG, "Couldn't set tile url", e);
}
}
mMinimumZoomLevel = getJSONFloat(this.tileJSON, "minzoom");
mMaximumZoomLevel = getJSONFloat(this.tileJSON, "maxzoom");
mName = this.tileJSON.optString("name");
mDescription = this.tileJSON.optString("description");
mAttribution = this.tileJSON.optString("attribution");
mLegend = this.tileJSON.optString("legend");
double[] center = getJSONDoubleArray(this.tileJSON, "center", 3);
if (center != null) {
mCenter = new LatLng(center[0], center[1], center[2]);
}
double[] bounds = getJSONDoubleArray(this.tileJSON, "bounds", 4);
if (bounds != null) {
mBoundingBox = new BoundingBox(bounds[3], bounds[2], bounds[1], bounds[0]);
}
}
if (UtilConstants.DEBUGMODE) {
// Log.d(TAG, "TileJSON " + this.tileJSON.toString());
}
}
开发者ID:RoProducts,项目名称:rastertheque,代码行数:33,代码来源:TileJsonTileLayer.java
示例15: goToMyPosition
import com.mapbox.mapboxsdk.geometry.BoundingBox; //导入依赖的package包/类
public boolean goToMyPosition(final boolean animated) {
if (mLocation == null) {
return false;
}
float currentZoom = mMapView.getZoomLevel(false);
if (currentZoom <= mRequiredZoomLevel) {
double requiredZoom = mRequiredZoomLevel;
if (mZoomBasedOnAccuracy && mMapView.isLayedOut()) {
double delta = (mLocation.getAccuracy() / 110000) * 1.2; // approx. meter per degree latitude, plus some margin
final Projection projection = mMapView.getProjection();
LatLng desiredSouthWest = new LatLng(mLocation.getLatitude() - delta,
mLocation.getLongitude() - delta);
LatLng desiredNorthEast = new LatLng(mLocation.getLatitude() + delta,
mLocation.getLongitude() + delta);
float pixelRadius = Math.min(mMapView.getMeasuredWidth(), mMapView.getMeasuredHeight()) / 2;
BoundingBox currentBox = projection.getBoundingBox();
if (desiredNorthEast.getLatitude() != currentBox.getLatNorth() ||
desiredNorthEast.getLongitude() != currentBox.getLonEast() ||
desiredSouthWest.getLatitude() != currentBox.getLatSouth() ||
desiredSouthWest.getLongitude() != currentBox.getLonWest()) {
mMapView.zoomToBoundingBox(new BoundingBox(desiredNorthEast, desiredSouthWest), true, animated, true);
}
} else if (animated) {
return mMapController.setZoomAnimated((float) requiredZoom, mLatLng, true, false);
} else {
mMapController.setZoom((float) requiredZoom, mLatLng, false);
}
} else if (animated) {
return mMapController.animateTo(mLatLng);
} else {
return mMapController.goTo(mLatLng, new PointF(0, 0));
}
return true;
}
开发者ID:RoProducts,项目名称:rastertheque,代码行数:38,代码来源:UserLocationOverlay.java
示例16: findBoundingBoxForGivenLocations
import com.mapbox.mapboxsdk.geometry.BoundingBox; //导入依赖的package包/类
/**
* Build a BoundingBox for a List of LatLng
* @param coordinates List of coordinates
* @param padding Option padding. Recommended 0.01. Send in null to have no padding applied
* @return BoundingBox containing the given List of LatLng
*/
public static BoundingBox findBoundingBoxForGivenLocations(List<LatLng> coordinates, Double padding) {
double west = 0.0;
double east = 0.0;
double north = 0.0;
double south = 0.0;
for (int lc = 0; lc < coordinates.size(); lc++) {
LatLng loc = coordinates.get(lc);
if (lc == 0) {
north = loc.getLatitude();
south = loc.getLatitude();
west = loc.getLongitude();
east = loc.getLongitude();
} else {
if (loc.getLatitude() > north) {
north = loc.getLatitude();
} else if (loc.getLatitude() < south) {
south = loc.getLatitude();
}
if (loc.getLongitude() < west) {
west = loc.getLongitude();
} else if (loc.getLongitude() > east) {
east = loc.getLongitude();
}
}
}
// OPTIONAL - Add some extra "padding" for better map display
if (padding != null) {
north = north + padding;
south = south - padding;
west = west - padding;
east = east + padding;
}
return new BoundingBox(north, east, south, west);
}
开发者ID:RoProducts,项目名称:rastertheque,代码行数:44,代码来源:GeoUtils.java
示例17: getTileLatLonBounds
import com.mapbox.mapboxsdk.geometry.BoundingBox; //导入依赖的package包/类
public BoundingBox getTileLatLonBounds() {
// Returns bounds of the given tile in EPSG:900913 coordinates
double[] bounds = TileBounds(this.getX(), this.getY(), this.getZ());
double[] minLatLon = MetersToLatLon(bounds[0], bounds[3]);
double[] maxLatLon = MetersToLatLon(bounds[2], bounds[1]);
return new BoundingBox(maxLatLon[0], maxLatLon[1], minLatLon[0], minLatLon[1]);
}
开发者ID:posm,项目名称:OpenMapKitAndroid,代码行数:9,代码来源:MapTile.java
示例18: initWithTileJSON
import com.mapbox.mapboxsdk.geometry.BoundingBox; //导入依赖的package包/类
private void initWithTileJSON(JSONObject aTileJSON) {
this.setTileJSON((aTileJSON != null) ? aTileJSON : new JSONObject());
if (aTileJSON != null) {
if (this.tileJSON.has("tiles")) {
try {
setURL(this.tileJSON.getJSONArray("tiles").getString(0).replace(".png", "{2x}.png"));
} catch (JSONException e) {
Log.e(TAG, "Couldn't set tile url", e);
}
}
mMinimumZoomLevel = getJSONFloat(this.tileJSON, "minzoom");
mMaximumZoomLevel = getJSONFloat(this.tileJSON, "maxzoom");
mName = this.tileJSON.optString("name");
mDescription = this.tileJSON.optString("description");
mAttribution = this.tileJSON.optString("attribution");
mLegend = this.tileJSON.optString("legend");
double[] center = getJSONDoubleArray(this.tileJSON, "center", 3);
if (center != null) {
mCenter = new LatLng(center[0], center[1], center[2]);
}
double[] bounds = getJSONDoubleArray(this.tileJSON, "bounds", 4);
if (bounds != null) {
mBoundingBox = new BoundingBox(bounds[3], bounds[2], bounds[1], bounds[0]);
}
}
if (UtilConstants.DEBUGMODE) {
Log.d(TAG, "TileJSON " + this.tileJSON.toString());
}
}
开发者ID:posm,项目名称:OpenMapKitAndroid,代码行数:31,代码来源:TileJsonTileLayer.java
示例19: updateBoundingBox
import com.mapbox.mapboxsdk.geometry.BoundingBox; //导入依赖的package包/类
public void updateBoundingBox(BoundingBox bbox) {
double x1 = bbox.getLonWest();
double x2 = bbox.getLonEast();
double y1 = bbox.getLatSouth();
double y2 = bbox.getLatNorth();
envelope = new Envelope(x1, x2, y1, y2);
}
开发者ID:posm,项目名称:OpenMapKitAndroid,代码行数:8,代码来源:OSMOverlay.java
示例20: OSMDownloader
import com.mapbox.mapboxsdk.geometry.BoundingBox; //导入依赖的package包/类
/**
*
* @param activity the Activity that is calling the OSMDownloader
* @param bbox the bounding box the map is at
*/
public OSMDownloader(Activity activity, BoundingBox bbox) {
super();
this.activity = activity;
this.bbox = bbox;
downloadManager = (DownloadManager) activity.getSystemService(Activity.DOWNLOAD_SERVICE);
}
开发者ID:posm,项目名称:OpenMapKitAndroid,代码行数:12,代码来源:OSMDownloader.java
注:本文中的com.mapbox.mapboxsdk.geometry.BoundingBox类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论