マピオンAPI


Android Maps APIドキュメント

位置を指定してアイコンを載せる

@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	
	MapView mapView = new MapView(this, new LightMap("APIキー"));
	mapView.setClickable(true);
	setContentView(mapView);
	
	mapView.setBuiltInZoomControls(true);
	
	mapView.getController().setCenter(new GeoPoint((int) (35.658611 * 1E6), (int) (139.745556 * 1E6)));
	mapView.getController().setZoom(mapView.getMaxZoomLevel());
	
	Overlay overlay = new Overlay() {
		@Override
		public void draw(Canvas canvas, MapView mapView, boolean shadow) {
			if (!shadow) {
				{
					Point pos = mapView.getProjection().toPixels(TOKYOTOWER, null);
					Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.kokodeneman);
					canvas.drawBitmap(bitmap, pos.x, pos.y - 13, null);
				}
				{
					Point pos = mapView.getProjection().toPixels(TOKYOTOWER, null);
					Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.kokodeneman_sakura);
					canvas.drawBitmap(bitmap, pos.x - bitmap.getWidth(), pos.y - 15, null);
				}
			}
		}
	};
	mapView.getOverlays().add(overlay);
}