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


Java MapView.getMapCenter方法代码示例

本文整理汇总了Java中com.google.android.maps.MapView.getMapCenter方法的典型用法代码示例。如果您正苦于以下问题:Java MapView.getMapCenter方法的具体用法?Java MapView.getMapCenter怎么用?Java MapView.getMapCenter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.android.maps.MapView的用法示例。


在下文中一共展示了MapView.getMapCenter方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: draw

import com.google.android.maps.MapView; //导入方法依赖的package包/类
@Override
public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) {
  if (image == null || shadow) {
    return false;
  }
  GeoPoint mapCenter = mapView.getMapCenter();
  float zoom = mapView.getProjection().metersToEquatorPixels(1.0f);
  if (zoom != lastDrawnZoom || !mapCenter.equals(lastDrawnLocation)) {
    computeImageWarp(mapView);
    lastDrawnZoom = zoom;
    lastDrawnLocation = mapCenter;
  }
  // Draw translucent map image
  canvas.drawBitmap(image, imageMatrix, transparency);
  // Highlight specified tie points with circles
  for (Point p : screenPoints) {
    canvas.drawCircle(p.x, p.y, 10, pointPaint);
  }
  return false;
}
 
开发者ID:markoteittinen,项目名称:custom-maps,代码行数:21,代码来源:WarpedImageOverlay.java

示例2: displayPoints

import com.google.android.maps.MapView; //导入方法依赖的package包/类
public void displayPoints(MapView m_MapView, Canvas canvas){
       //		Log.e(TAG, "displayPoints(..) called.");
       //		Log.e(TAG, "pixelRadius == "+pixelRadius);

	// calculate the lat/long span of the screen
	int latSpan = m_MapView.getLatitudeSpan();
	int longSpan = m_MapView.getLongitudeSpan();
	GeoPoint mapCenter = m_MapView.getMapCenter();
	int halfLatSpan = (latSpan/2);
	int halfLongSpan = (longSpan/2);
	int latitudeE6TopEdge = mapCenter.getLatitudeE6()  + halfLatSpan;
	int longitudeE6ToTop = mapCenter.getLongitudeE6() + halfLongSpan;
	
	int latitudeE6BottomEdge = mapCenter.getLatitudeE6()  - halfLatSpan;
	int longitudeE6BottomTop = mapCenter.getLongitudeE6() - halfLongSpan;
	
	GeoPoint upperRightCornerPoint = new GeoPoint(latitudeE6TopEdge, longitudeE6ToTop);
	GeoPoint lowerLeftCornerPoint = new GeoPoint(latitudeE6BottomEdge, longitudeE6BottomTop);
	
	Paint spot = new Paint();
	spot.setStyle(Paint.Style.FILL);

	Point xyCoords = mMapView.getProjection().toPixels(upperRightCornerPoint, null);
	
	int mapTopEdge = xyCoords.y;
	int mapRightEdge = xyCoords.x;
	
	xyCoords = mMapView.getProjection().toPixels(lowerLeftCornerPoint, xyCoords);

	int mapBottomEdge = xyCoords.y;
	int mapLeftEdge = xyCoords.x;
	
	xyCoords = mMapView.getProjection().toPixels(mPoint, xyCoords);
}
 
开发者ID:SpencerRiddering,项目名称:flingtap-done,代码行数:35,代码来源:ProximityOverlay.java

示例3: getCurrBounds

import com.google.android.maps.MapView; //导入方法依赖的package包/类
public static Rect getCurrBounds(MapView map) {
	int longSpan = map.getLongitudeSpan();
	int latSpan = map.getLatitudeSpan();
	GeoPoint currentCenter = map.getMapCenter();
	return new Rect(currentCenter.getLongitudeE6() - longSpan / 2,
			currentCenter.getLatitudeE6() - latSpan / 2,
			currentCenter.getLongitudeE6() + longSpan / 2,
			currentCenter.getLatitudeE6() + latSpan / 2);
}
 
开发者ID:Mapyst,项目名称:Mapyst,代码行数:10,代码来源:MapUtils.java

示例4: draw

import com.google.android.maps.MapView; //导入方法依赖的package包/类
@Override
public void draw(final Canvas c, final MapView osmv, final boolean shadow) {
	if (DEBUGMODE) {
              Log.d(Constants.LOGTAG, "draw");
	}

	// Calculate the half-world size
	final Projection pj = osmv.getProjection();
	final int zoomLevel = osmv.getZoomLevel() - 1;
	final int tileSizePx = this.mTileProvider.getTileSource().getTileSizePixels();

	// Calculate the tiles needed for each side around the center one.
	final int latSpan = osmv.getLatitudeSpan();
	final int longSpan = osmv.getLongitudeSpan();
	final int topLatitude = osmv.getMapCenter().getLatitudeE6() + latSpan/2;
	final int leftLongitude = osmv.getMapCenter().getLongitudeE6() - longSpan/2;
	final int bottomLatitude = osmv.getMapCenter().getLatitudeE6() - latSpan/2;
	final int rightLongitude = osmv.getMapCenter().getLongitudeE6() + longSpan/2;
	final Point leftTopXY = Mercator.projectGeoPoint(topLatitude*1E-6, leftLongitude*1E-6, zoomLevel, new Point(0,0));
	final Point rightBottomXY = Mercator.projectGeoPoint(bottomLatitude*1E-6, rightLongitude*1E-6, zoomLevel, new Point(0,0));
	final int tileNeededAtLeft = leftTopXY.x;
	final int tileNeededAtRight = rightBottomXY.x;
	final int tileNeededAtTop = leftTopXY.y;
	final int tileNeededAtBottom = rightBottomXY.y;

	final int mapTileUpperBound = 1 << zoomLevel;
	// make sure the cache is big enough for all the tiles
	final int numNeeded = (tileNeededAtBottom - tileNeededAtTop + 1)
			* (tileNeededAtRight - tileNeededAtLeft + 1);
	mTileProvider.ensureCapacity(numNeeded);
	/* Draw all the MapTiles (from the upper left to the lower right). */
	for (int y = tileNeededAtTop; y <= tileNeededAtBottom; y++) {
		for (int x = tileNeededAtLeft; x <= tileNeededAtRight; x++) {
			// Construct a MapTile to request from the tile provider.
			final int tileY = MyMath.mod(y, mapTileUpperBound);
			final int tileX = MyMath.mod(x, mapTileUpperBound);
			final MapTile tile = new MapTile(zoomLevel, tileX, tileY);
			final Drawable currentMapTile = mTileProvider.getMapTile(tile);
			if (currentMapTile != null) {
				final GeoPoint gp = new GeoPoint(
						(int) (Mercator.tile2lat(y, zoomLevel) * 1E6),
						(int) (Mercator.tile2lon(x, zoomLevel) * 1E6));
				pj.toPixels(gp, mTilePos);
				mTileRect.set(mTilePos.x, mTilePos.y, mTilePos.x + tileSizePx, mTilePos.y + tileSizePx);
				currentMapTile.setBounds(mTileRect);
				currentMapTile.draw(c);
			}

			if (DEBUGMODE) {
				c.drawText(tile.toString(), mTileRect.left + 1, mTileRect.top + mPaint.getTextSize(), mPaint);
				c.drawLine(mTileRect.left, mTileRect.top, mTileRect.right, mTileRect.top, mPaint);
				c.drawLine(mTileRect.left, mTileRect.top, mTileRect.left, mTileRect.bottom, mPaint);
			}
		}
	}

	// draw a cross at center in debug mode
	if (DEBUGMODE) {
		final GeoPoint center = osmv.getMapCenter();
		final Point centerPoint = pj.toPixels(center, null);
		c.drawLine(centerPoint.x, centerPoint.y - 9, centerPoint.x, centerPoint.y + 9, mPaint);
		c.drawLine(centerPoint.x - 9, centerPoint.y, centerPoint.x + 9, centerPoint.y, mPaint);
	}
}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:65,代码来源:GoogleTilesOverlay.java

示例5: smoothMove

import com.google.android.maps.MapView; //导入方法依赖的package包/类
public static void smoothMove(final MapView mapView, Handler handler, GeoPoint targetCenter, final int targetLongSpan,
		final int targetLatSpan, boolean zoom, Running running) {
	final MapController mControl = mapView.getController();

	// a Quick runnable to zoom in
	GeoPoint currentCenter = mapView.getMapCenter();

	// yes brandon, we need doubles.

	double currentLat = currentCenter.getLatitudeE6();
	double currentLong = currentCenter.getLongitudeE6();

	final int targetLat = targetCenter.getLatitudeE6();
	final int targetLong = targetCenter.getLongitudeE6();

	int rateOfChange = 100;

	double deltaLong = 0;
	double deltaLat = 0;

	deltaLat = -(currentLat - targetLat) / rateOfChange;
	deltaLong = -(currentLong - targetLong) / rateOfChange;

	long delay = 0;
	while (!equalWithinEpsilon(currentLat, targetLat, deltaLat * 2)	|| !equalWithinEpsilon(currentLong, targetLong, deltaLong * 2)) {

		if (!equalWithinEpsilon(currentLong, targetLong, deltaLong * 2)) {
			currentLong += deltaLong;
		}
		if (!equalWithinEpsilon(currentLat, targetLat, deltaLat * 2)) {
			currentLat += deltaLat;
		}
		final int newLong = (int) currentLong;
		final int newLat = (int) currentLat;

		handler.postDelayed(new RunnableMover(mControl, new GeoPoint(newLat, newLong), running), delay);

		delay += 5;
		if (delay > 1000) // just so we don't get stuck in an infinite loop
			break;
	}
	// System.out.println(delay);
	handler.postDelayed(new RunnableMover(mControl, new GeoPoint(targetLat, targetLong), running), delay);
	if (zoom) {
		AnimatedMapZoomer amz = new AnimatedMapZoomer(mapView, handler, targetLatSpan, targetLongSpan, delay);
		new Thread(amz).start();
	}

}
 
开发者ID:Mapyst,项目名称:Mapyst,代码行数:50,代码来源:MapViewMover.java


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