マピオンAPI


Android Maps APIドキュメント

位置を指定して円を描く

@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	MapView mapView = new MapView(this, "APIキー");
	mapView.setClickable(true);
	setContentView(mapView);
	
	mapView.setBuiltInZoomControls(true);
	
	mapView.getController().setCenter(new GeoPoint((int) (35.641625 * 1E6), (int) (139.749803 * 1E6)));
	mapView.getController().setZoom(mapView.getMaxZoomLevel() - 2);

	Overlay overlay = new Overlay() {
		@Override
		public void draw(Canvas canvas, MapView mapView, boolean shadow) {
			if (!shadow) {
				GeoPoint p = new GeoPoint((int) (35.641625 * 1E6), (int) (139.749803 * 1E6));
				
				Point pos = mapView.getProjection().toPixels(p, null);
				
				Paint fillPaint = new Paint();
				fillPaint.setColor(Color.argb(30, 0, 0, 255));
				fillPaint.setAntiAlias(true);
				fillPaint.setStyle(Paint.Style.FILL);

				canvas.drawCircle(pos.x, pos.y, 80.0f, fillPaint);
				
				Paint strokePaint = new Paint();
				strokePaint.setColor(Color.argb(100, 0, 0, 255));
				strokePaint.setAntiAlias(true);
				strokePaint.setStrokeWidth(3);
				strokePaint.setStyle(Paint.Style.STROKE);
				
				canvas.drawCircle(pos.x, pos.y, 80.f, strokePaint);
				
				
			}
		}
	};
	mapView.getOverlays().add(overlay);
}