本文整理汇总了Java中org.osmdroid.views.MapView.getIntrinsicScreenRect方法的典型用法代码示例。如果您正苦于以下问题:Java MapView.getIntrinsicScreenRect方法的具体用法?Java MapView.getIntrinsicScreenRect怎么用?Java MapView.getIntrinsicScreenRect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.osmdroid.views.MapView
的用法示例。
在下文中一共展示了MapView.getIntrinsicScreenRect方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clusterer
import org.osmdroid.views.MapView; //导入方法依赖的package包/类
/** Grid-based clustering algorithm */
@Override public ArrayList<StaticCluster> clusterer(MapView mapView){
Rect mScreenRect = mapView.getIntrinsicScreenRect(null);
BoundingBoxE6 bb = mapView.getBoundingBox();
double latSpan = bb.getLatitudeSpanE6()*1E-6;
double lonSpan = bb.getLongitudeSpanE6()*1E-6;
//Log.d("ZOOM", "latSpan="+latSpan+" lonSpan="+lonSpan);
//convert grid size from pixels to degrees:
double gridSizeX, gridSizeY;
gridSizeX = lonSpan * (double)mGridSize / (double)(mScreenRect.right - mScreenRect.left);
gridSizeY = latSpan * (double)mGridSize / (double)(mScreenRect.bottom - mScreenRect.top);
int numCellsW = (int)(360.0f/gridSizeX);
//Log.d("ZOOM", "zoomlevel="+mapView.getZoomLevel()+" cells="+numCellsW);
//Log.d("ZOOM", "gridSizeX="+gridSizeX+" gridSizeY="+gridSizeY);
ArrayList<StaticCluster> clusters = new ArrayList<StaticCluster>();
LongSparseArray<StaticCluster> sparseArray = new LongSparseArray<StaticCluster>();
for (Marker item:mItems){
//TODO - add 180° to prevent negative values
long gridX = (long)(item.getPosition().getLongitude() / gridSizeX);
long gridY = (long)(item.getPosition().getLatitude() / gridSizeY);
long coord = numCellsW * gridX + gridY;
StaticCluster cluster = sparseArray.get(coord);
//Log.d("ZOOM", "coord="+coord+" =>cluster:"+(cluster==null?"new":"add"));
if (cluster == null) {
//GeoPoint clusterCorner = new GeoPoint(gridSizeY*(double)gridY, gridSizeX*(double)gridX);
cluster = new StaticCluster(item.getPosition() /*clusterCorner*/);
sparseArray.put(coord, cluster);
clusters.add(cluster);
}
cluster.add(item);
}
return clusters;
}
示例2: clusterer
import org.osmdroid.views.MapView; //导入方法依赖的package包/类
/** Grid-based clustering algorithm */
@Override public ArrayList<StaticCluster> clusterer(MapView mapView){
Rect mScreenRect = mapView.getIntrinsicScreenRect(null);
BoundingBox bb = mapView.getBoundingBox();
double latSpan = bb.getLatitudeSpan();
double lonSpan = bb.getLongitudeSpan();
//Log.d("ZOOM", "latSpan="+latSpan+" lonSpan="+lonSpan);
//convert grid size from pixels to degrees:
double gridSizeX, gridSizeY;
gridSizeX = lonSpan * (double)mGridSize / (double)(mScreenRect.right - mScreenRect.left);
gridSizeY = latSpan * (double)mGridSize / (double)(mScreenRect.bottom - mScreenRect.top);
int numCellsW = (int)(360.0f/gridSizeX);
//Log.d("ZOOM", "zoomlevel="+mapView.getZoomLevel()+" cells="+numCellsW);
//Log.d("ZOOM", "gridSizeX="+gridSizeX+" gridSizeY="+gridSizeY);
ArrayList<StaticCluster> clusters = new ArrayList<StaticCluster>();
LongSparseArray<StaticCluster> sparseArray = new LongSparseArray<StaticCluster>();
for (Marker item:mItems){
//TODO - add 180° to prevent negative values
long gridX = (long)(item.getPosition().getLongitude() / gridSizeX);
long gridY = (long)(item.getPosition().getLatitude() / gridSizeY);
long coord = numCellsW * gridX + gridY;
StaticCluster cluster = sparseArray.get(coord);
//Log.d("ZOOM", "coord="+coord+" =>cluster:"+(cluster==null?"new":"add"));
if (cluster == null) {
//GeoPoint clusterCorner = new GeoPoint(gridSizeY*(double)gridY, gridSizeX*(double)gridX);
cluster = new StaticCluster(item.getPosition() /*clusterCorner*/);
sparseArray.put(coord, cluster);
clusters.add(cluster);
}
cluster.add(item);
}
return clusters;
}
示例3: convertRadiusToMeters
import org.osmdroid.views.MapView; //导入方法依赖的package包/类
private void convertRadiusToMeters(MapView mapView) {
Rect mScreenRect = mapView.getIntrinsicScreenRect(null);
int screenWidth = mScreenRect.right - mScreenRect.left;
int screenHeight = mScreenRect.bottom - mScreenRect.top;
BoundingBoxE6 bb = mapView.getBoundingBox();
double diagonalInMeters = bb.getDiagonalLengthInMeters();
double diagonalInPixels = Math.sqrt(screenWidth * screenWidth + screenHeight * screenHeight);
double metersInPixel = diagonalInMeters / diagonalInPixels;
mRadiusInMeters = mRadiusInPixels * metersInPixel;
}
示例4: convertRadiusToMeters
import org.osmdroid.views.MapView; //导入方法依赖的package包/类
private void convertRadiusToMeters(MapView mapView) {
Rect mScreenRect = mapView.getIntrinsicScreenRect(null);
int screenWidth = mScreenRect.right - mScreenRect.left;
int screenHeight = mScreenRect.bottom - mScreenRect.top;
BoundingBox bb = mapView.getBoundingBox();
double diagonalInMeters = bb.getDiagonalLengthInMeters();
double diagonalInPixels = Math.sqrt(screenWidth * screenWidth + screenHeight * screenHeight);
double metersInPixel = diagonalInMeters / diagonalInPixels;
mRadiusInMeters = mRadiusInPixels * metersInPixel;
}