GeoPoint gPointA = _points.get(i); Point pointA = new Point(); projection.toPixels(gPointA, pointA); if (i == 0) { //This is the start point startPoint = pointA;
projection.toPixels(gP2, p2);
if(mapView != null){ Projection projection = mapView.getProjection(); if(projection != null){ mScreenPoints = projection.toPixels(pointToDraw, mScreenPoints); } else{ // log it projection is null } } else{ //log it mapView is null }
public boolean onTap(GeoPoint p, MapView mapView) { Projection projection = mapView.getProjection(); projection.toPixels(yourMarkerGeopoint, pointTap); yourMarker.copyBounds(boundsTap); boundsTap.offset(pointTap.x, pointTap.y); projection.toPixels(geoPoint, pointTap); if(boundsTap.contains(pointTap.x, pointTap.y)){ //you tap on the marker return true; } return false; }
OverlayItem item = overlayItems_.get(index); Projection projection = mMapView.getProjection(); Point point = new Point(); projection.toPixels(item.getPoint(), point); Toast toast = Toast.makeText(mContext, item.getTitle()+" "+item.getSnippet(), Toast.LENGTH_SHORT); toast.setGravity(Gravity.TOP | Gravity.LEFT, point.x, point.y); toast.show();
float pisteX; float pisteY; Projection projection = this.mapView.getProjection(); Point pt = new Point(); GeoPoint gie = new GeoPoint(latitude,longitude); Rect rec = mapView.getScreenRect(new Rect()); projection.toPixels(gie, pt); pisteX = pt.x-rec.left; // car X screen coord pisteY = pt.y-rec.top; // car Y screen coord
public void draw(Canvas canvas, MapView mapView, boolean shadow){ super.draw(canvas, mapView, shadow); path = new Path(); Projection proj = mapView.getProjection(); proj.toPixels(gp1, p1); proj.toPixels(gp2, p2); path.moveTo(p2.x, p2.y); path.lineTo(p1.x,p1.y); canvas.drawPath(path, somePaintObject); }
Point screenPts = new Point(); @Override protected void drawOverlayBitmap(Canvas canvas, Point point, Projection projection, byte zoom){ projection.toPixels(new GeoPoint((int)(location.getLatitude()*1E6), (int)(location.getLongitude()*1E6)) , screenPts); canvas.drawBitmap(myBitmap, screenPts.x, screenPts.y, new Paint()); }
Projection projection = mapView.getProjection(); Point center = projection.toPixels(new GeoPoint(yourLat * E6, yourLong * E6), null); float radius = projection.metersToEquatorPixels(radiusInMeters); canvas.draw(center.x, center.y, radius, new Paint());
Projection projection = map.getProjection(); projection.toPixels(geoPointBefore, pt); geoPointAfter = projection.fromPixels(pt.x, pt.y); int diffLatitude = geoPointBefore.getLatitudeE6() - geoPointAfter.getLatitudeE6(); int diffLongitude = geoPointBefore.getLongitudeE6() - geoPointAfter.getLongitudeE6(); ... ... ... // Add the difference to GeoPoint objects after conversion `fromPixels`
public class CrossHairsOverlay extends Overlay { public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) { super.draw(canvas, mapView, shadow); GeoPoint centerGp = mapView.getMapCenter(); Projection projection = mapView.getProjection(); Point centerPoint = projection.toPixels(centerGp, null); Paint p = new Paint(); Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.crosshairs_dial); canvas.drawBitmap(bmp, centerPoint.x, centerPoint.y, p); return true; } }
public static void panMap (int x, int y, MapView map) { Point ptPixels = new Point(); GeoPoint geoPt = map.getMapCenter(); Projection projection = map.getProjection(); projection.toPixels(geoPt, ptPixels); ptPixels.x += x; ptPixels.y += y; geoPt = projection.fromPixels(ptPixels.x, ptPixels.y); map.getController().animateTo(geoPt); }