当前位置: 首页>>代码示例>>Java>>正文


Java MapView.getIntrinsicScreenRect方法代码示例

本文整理汇总了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;
}
 
开发者ID:jeffallen,项目名称:MarshrutMe,代码行数:38,代码来源:GridMarkerClusterer.java

示例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;
}
 
开发者ID:MKergall,项目名称:osmbonuspack,代码行数:38,代码来源:GridMarkerClusterer.java

示例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;
    }
 
开发者ID:BackPackerDz,项目名称:Android-Tariki.dz,代码行数:16,代码来源:RadiusMarkerClusterer.java

示例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;
    }
 
开发者ID:MKergall,项目名称:osmbonuspack,代码行数:16,代码来源:RadiusMarkerClusterer.java


注:本文中的org.osmdroid.views.MapView.getIntrinsicScreenRect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。