add Viewport.getBBox(int expand) to expand by gived pixels

This commit is contained in:
Hannes Janetzek 2014-02-09 17:15:22 +01:00
parent 4dfbf1f088
commit d3c03fb564
2 changed files with 9 additions and 5 deletions

View File

@ -169,7 +169,7 @@ public class ItemizedLayer<Item extends MarkerItem> extends MarkerLayer<Item>
int eventY = (int) event.getY() - mMap.getHeight() / 2;
Viewport mapPosition = mMap.viewport();
BoundingBox bbox = mapPosition.getBBox();
BoundingBox bbox = mapPosition.getBBox(128);
int nearest = -1;
int inside = -1;

View File

@ -226,8 +226,8 @@ public class Viewport {
*
* @return BoundingBox containing view
*/
public synchronized BoundingBox getBBox() {
getBBox(mMapBBox);
public synchronized BoundingBox getBBox(int expand) {
getBBox(mMapBBox, expand);
// scale map-pixel coordinates at current scale to
// absolute coordinates and apply mercator projection.
@ -240,14 +240,18 @@ public class Viewport {
return new BoundingBox(minLat, minLon, maxLat, maxLon);
}
public synchronized BoundingBox getBBox() {
return getBBox(0);
}
/**
* Get the minimal axis-aligned BoundingBox that encloses
* the visible part of the map. Sets box to map coordinates:
* minX,minY,maxY,maxY
*/
public synchronized void getBBox(Box box) {
public synchronized void getBBox(Box box, int expand) {
float[] coords = mViewCoords;
getMapExtents(coords, 0);
getMapExtents(coords, expand);
box.minX = coords[0];
box.maxX = coords[0];