本文整理汇总了Java中com.google.android.maps.MapView.getProjection方法的典型用法代码示例。如果您正苦于以下问题:Java MapView.getProjection方法的具体用法?Java MapView.getProjection怎么用?Java MapView.getProjection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.maps.MapView
的用法示例。
在下文中一共展示了MapView.getProjection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: draw
import com.google.android.maps.MapView; //导入方法依赖的package包/类
@Override
public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) {
Projection projection = mapView.getProjection();
if (shadow == false && mapView.getZoomLevel() >= minZoom) {
int zoomExtra = mapView.getZoomLevel() - minZoom;
Paint rectPaint = new Paint();
Paint textPaint = new Paint();
Point point = new Point();
projection.toPixels(gp, point);
rectPaint.setColor(Color.GRAY);
rectPaint.setAlpha(128);
rectPaint.setStrokeWidth(2);
textPaint.setTextSize(baseTextSize + (zoomExtra * 2));
textPaint.setAntiAlias(true);
//textPaint.setColor(Color.RED);
textPaint.setColor(Color.parseColor(color));
textPaint.setTextAlign(Align.LEFT);
float textwidth = textPaint.measureText(text);
canvas.drawRect(point.x, point.y, point.x + 4 + textwidth, point.y + 4 + textPaint.getTextSize(), rectPaint);
rectPaint.setColor(Color.WHITE);
canvas.drawCircle(point.x + 2, point.y + 2, 4, rectPaint);
canvas.drawText(text, point.x + 1, point.y + textPaint.getTextSize(), textPaint);
}
return super.draw(canvas, mapView, shadow, when);
}
示例2: DragableOverlay
import com.google.android.maps.MapView; //导入方法依赖的package包/类
public DragableOverlay(AndroidPin pin, MapView mapview) {
mPin = pin;
mMapView = mapview;
mProjector = mapview.getProjection();
mVibrator = (Vibrator)mapview.getContext().getSystemService(Context.VIBRATOR_SERVICE);
newPosition = pin.mPoint;
targetDrawable = mapview.getContext().getResources().getDrawable(R.drawable.target);
int width = targetDrawable.getIntrinsicWidth();
int height = targetDrawable.getIntrinsicHeight();
int w2 = width / 2;
int h2 = height / 2;
targetDrawable.setBounds(-w2, -h2, w2,h2);
}
示例3: draw
import com.google.android.maps.MapView; //导入方法依赖的package包/类
@Override
public void draw(Canvas canvas, MapView map, boolean shadow) {
if (shadow || this.location == null) {
return;
}
Projection proj = map.getProjection();
// check whether the current location is on the visible map
this.currentLocationOnScreen = checkCurrentLocationOnScreen(map, proj);
proj.toPixels(this.location, this.tmpPoint);
float radius = proj.metersToEquatorPixels(this.accuracyAdjusted);
canvas.drawCircle(this.tmpPoint.x, this.tmpPoint.y, radius, paintFill);
canvas.drawCircle(this.tmpPoint.x, this.tmpPoint.y, radius, paintOuter);
}
示例4: draw
import com.google.android.maps.MapView; //导入方法依赖的package包/类
@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
if (shadow) return;
Projection proj = mapView.getProjection();
MapAreaData mapData = mapArea.mapData;
Path path = new Path();
pt = proj.toPixels(mapData.corners[0].asGeoPoint(), pt);
path.moveTo(pt.x, pt.y);
for (int i = 1; i < mapData.corners.length; i++) {
proj.toPixels(mapData.corners[i].asGeoPoint(), pt);
path.lineTo(pt.x, pt.y);
}
proj.toPixels(mapData.corners[0].asGeoPoint(), pt);
path.lineTo(pt.x, pt.y);
canvas.drawPath(path, paintFill);
canvas.drawPath(path, paintStroke);
}
示例5: draw
import com.google.android.maps.MapView; //导入方法依赖的package包/类
@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
if (shadow) {
super.draw(canvas, mapView, shadow);
return;
}
Projection proj = mapView.getProjection();
android.graphics.Path directionsPath = new android.graphics.Path();
pt = proj.toPixels(directions.paths[0].coord.asGeoPoint(), pt);
directionsPath.moveTo(pt.x, pt.y);
for (int i = 1; i < directions.paths.length; i++) {
DirectionPath path = directions.paths[i];
proj.toPixels(path.coord.asGeoPoint(), pt);
directionsPath.lineTo(pt.x, pt.y);
}
canvas.drawPath(directionsPath, pathPaint);
super.draw(canvas, mapView, shadow);
}
示例6: draw
import com.google.android.maps.MapView; //导入方法依赖的package包/类
@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
if (!shadow) {
Point point = new Point();
Projection p = mapView.getProjection();
p.toPixels(mItem.getLocation(), point);
super.draw(canvas, mapView, shadow);
drawAt(canvas, mMarker, point.x + mMarkerXOffset, point.y + mMarkerYOffset, shadow);
}
}
示例7: computeImageWarp
import com.google.android.maps.MapView; //导入方法依赖的package包/类
/**
* Computes the matrix required to warp the image over MapView to match image
* points with geo points.
*
* @return {@code true} if the imageMatrix was successfully resolved
*/
public boolean computeImageWarp(MapView map) {
Projection projection = map.getProjection();
int i = 0;
for (GeoPoint gp : geoPoints) {
Point sp = screenPoints.get(i++);
projection.toPixels(gp, sp);
}
float[] imageCoords = createPointFloatArray(imagePoints);
float[] screenCoords = createPointFloatArray(screenPoints);
// Use at most 4 tiepoints
int n = Math.min(4, imagePoints.size());
boolean ok = imageMatrix.setPolyToPoly(imageCoords, 0, screenCoords, 0, n);
if (!ok) {
// If we failed using 4 points, drop last one
if (n == 4) {
ok = imageMatrix.setPolyToPoly(imageCoords, 0, screenCoords, 0, n - 1);
}
}
return ok;
}
示例8: draw
import com.google.android.maps.MapView; //导入方法依赖的package包/类
@Override
public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) {
Projection projection = mapView.getProjection();
if (shadow == false) {
Paint paint = new Paint();
Point point = new Point();
projection.toPixels(gp, point);
paint.setColor(Color.RED);
paint.setAlpha(64);
paint.setAntiAlias(true);
canvas.drawCircle(point.x, point.y, mapView.getProjection().metersToEquatorPixels(150), paint);
}
return super.draw(canvas, mapView, shadow, when);
}
示例9: draw
import com.google.android.maps.MapView; //导入方法依赖的package包/类
public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) {
Projection projection = mapView.getProjection();
if (shadow == false && _points != null) {
Point startPoint = null, endPoint = null;
Path path = new Path();
//We are creating the path
for (int i = 0; i < _points.size(); i++) {
GeoPoint gPointA = _points.get(i);
Point pointA = new Point();
projection.toPixels(gPointA, pointA);
if (i == 0) { //This is the start point
startPoint = pointA;
path.moveTo(pointA.x, pointA.y);
} else {
if (i == _points.size() - 1)//This is the end point
endPoint = pointA;
path.lineTo(pointA.x, pointA.y);
}
}
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setColor(_pathColor);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(5);
paint.setAlpha(90);
if (getDrawStartEnd()) {
if (startPoint != null) {
drawOval(canvas, paint, startPoint);
}
if (endPoint != null) {
drawOval(canvas, paint, endPoint);
}
}
if (!path.isEmpty())
canvas.drawPath(path, paint);
}
return super.draw(canvas, mapView, shadow, when);
}
示例10: draw
import com.google.android.maps.MapView; //导入方法依赖的package包/类
/**
* Draws the overlay track on the canvas
* @param canvas Reference to the {@link android.graphics.Canvas} to drawn on
* @param mapView Reference to the {@link com.google.android.maps.MapView} that the track appears on
* @param shadow draws a shadow (true) or not (false) under the track
* @param when not used here but required, simply forwarded to super method
*/
@Override
public boolean draw(Canvas canvas, MapView mapView, boolean shadow,
long when)
{
Projection projection = mapView.getProjection();
if (shadow == false)
{
Paint paint = new Paint();
paint.setAntiAlias(true);
Point point = new Point();
projection.toPixels(gp1, point);
paint.setColor(Color.BLUE);
Point point2 = new Point();
projection.toPixels(gp2, point2);
// stroke width depends on zoom level
int zoomLevel = mapView.getZoomLevel();
if (zoomLevel > 18)
paint.setStrokeWidth(6);
else
paint.setStrokeWidth(4);
// now draw line
canvas.drawLine((float) point.x, (float) point.y, (float) point2.x,(float) point2.y, paint);
}
return super.draw(canvas, mapView, shadow, when);
}
示例11: draw
import com.google.android.maps.MapView; //导入方法依赖的package包/类
public void draw(Canvas canvas, MapView mapv, boolean shadow){
super.draw(canvas, mapv, shadow);
Paint mPaint = new Paint();
mPaint.setDither(true);
mPaint.setColor(Color.RED);
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
mPaint.setStrokeJoin(Paint.Join.ROUND);
mPaint.setStrokeCap(Paint.Cap.ROUND);
mPaint.setStrokeWidth(2);
//select Route - array of arrays (points)
GeoPoint gP1 = null;
GeoPoint gP2 = null;
Point p1 = new Point();
Point p2 = new Point();
Path path = new Path();
Projection projection = mapv.getProjection();
projection.toPixels(gP1, p1);
projection.toPixels(gP2, p2);
path.moveTo(p2.x, p2.y);
path.lineTo(p1.x,p1.y);
canvas.drawPath(path, mPaint);
}
示例12: draw
import com.google.android.maps.MapView; //导入方法依赖的package包/类
@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow)
{
int pradius=(int) mapv.getProjection().metersToEquatorPixels(radius);
Log.i("MapViewer", " ==> Draw pos: " +gp1.toString() + " color: " + color + " radius: " + radius + " pradius: " + pradius );
Projection projection = mapView.getProjection();
Paint paint = new Paint();
Point point = new Point();
projection.toPixels(gp1, point);
paint.setColor(color);
paint.setStrokeWidth(0);
paint.setAlpha(20);
canvas.drawCircle(point.x, point.y, pradius, paint);
}
示例13: onSnapToItem
import com.google.android.maps.MapView; //导入方法依赖的package包/类
@Override
public boolean onSnapToItem(int x, int y, android.graphics.Point snapPoint, MapView mapView) {
Projection proj = mapView.getProjection();
GeoPoint geoPt = proj.fromPixels(x, y);
if (bounds.contains(geoPt.getLatitudeE6(), geoPt.getLongitudeE6())) {
proj.toPixels(mapArea.center.asGeoPoint(), snapPoint);
return true;
}
return false;
}
示例14: redrawPath
import com.google.android.maps.MapView; //导入方法依赖的package包/类
private void redrawPath(final MapView mv) {
final Projection prj = mv.getProjection();
path.rewind();
final Iterator<GeoPoint> it = mPoints.iterator();
prj.toPixels(it.next(), p);
path.moveTo(p.x, p.y);
while (it.hasNext()) {
prj.toPixels(it.next(), p);
path.lineTo(p.x, p.y);
}
path.setLastPoint(p.x, p.y);
}
示例15: redrawTextPath
import com.google.android.maps.MapView; //导入方法依赖的package包/类
private void redrawTextPath(final MapView mv) {
final Projection prj = mv.getProjection();
textPath.rewind();
prj.toPixels(mTextLeft, p);
textPath.moveTo(p.x, p.y);
prj.toPixels(mTextRight, p);
textPath.lineTo(p.x, p.y);
textPath.setLastPoint(p.x, p.y);
}