マピオンAPI


Android Maps APIドキュメント

緯度経度を指定して移動する

@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	
	LinearLayout layout = new LinearLayout(this);
	setContentView(layout);
	layout.setOrientation(LinearLayout.VERTICAL);

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

	Button button = new Button(this);
	button.setText("クリック");
	button.setOnClickListener(new OnClickListener() {
		@Override
		public void onClick(View v) {
			mapView.getController().animateTo(new GeoPoint((int) (35.7 * 1E6), (int) (139.7 * 1E6)));
		}
	});

	layout.addView(button, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
	layout.addView(mapView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
}