3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Yahoo! AndroidマップSDKで現在位置を追跡表示する

Last updated at Posted at 2012-06-19

公式サイトのドキュメントに掲載されていたコードでは、どうも動かないので修正版を。

公式サイトのコードはこちら。 http://developer.yahoo.co.jp/webapi/map/openlocalplatform/v1/androidsdk/tutorial16.html
*バグがありました。初回起動時にクラッシュします。現在は修正しました。

MainActivity.java
	/** 画面に表示するMapView */
	transient MapView mapView;
	/** 地図のコントローラー */
	transient MapController mapController;
	/** 現在位置を表示するオーバーレイ */
	transient NowLocationOverlay locationOverlay;

	/** Activity生成時により呼び出されるメソッド。地図の初期化なんかを行う。 */
	@Override
	public void onCreate(final Bundle sIState) {
		super.onCreate(sIState);
		mapView = new MapView(this, YOLP_ID);
		mapView.setBuiltInZoomControls(true);
		mapController = mapView.getMapController();
		// MyLocationOverlay のサブクラスであるNowLocationOverlayのインスタンスを作成
		locationOverlay = new NowLocationOverlay(getApplicationContext(),
				mapView);
		// センサーにはGPSを選択
		//locationOverlay.onProviderEnabled(LocationManager.GPS_PROVIDER);
		// 現在地取得開始
		locationOverlay.enableMyLocation();
		// MapViewにOverlayを追加
		mapView.getOverlays().add(locationOverlay);
		mapView.invalidate();
		setContentView(mapView);
	}

	@Override
	protected void onPause() {
		// 現在位置取得終了
		locationOverlay.disableMyLocation();
		// 不要?
		locationOverlay.onProviderDisabled(LocationManager.GPS_PROVIDER);
		super.onPause();
	}

MyLocationOverlayのサブクラスの実装は公式サイトのものと同じです。

また、今回はLocationManager.GPS_PROVIDERを利用して明示的にGPSを選択肢ましたが場合によっては、LocationManager.getBestProviderを利用したほうがイイかもしれません。

日本語のドキュメントや、GoogleMapSDKとほぼ同じAPI群など利用しやすいYahoo!AndroidマップSDKですが、まだまだな部分も多いように感じます。

とは言え、GoogleMapsに負けない詳細地図や一分施設の建物内の地図、ルート検索APIをデフォルトで実装していることなど便利な部分もやはり多いです。今後の発展に期待ですね。

しかし、このフィードバックをYahooに送信するにはどこから行えばいいんでしょうかね?

3
3
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?