LoginSignup
2
3

More than 5 years have passed since last update.

osmdroid を使ってAndroid の OpenStreetMap 地図にカスタムタイルを重ねる

Last updated at Posted at 2019-02-06

osmdroid を使って OpenStreetMap を Android に表示する
の続きです

OpenStreetMap は、共通の地図情報から任意のタイルを生成することができる。
その種のタイルをカスタムタイルと呼ぶ。

カスタムタイルの一覧

MainActivity.java

カスタムタイルは OSM日本 を使用する。

        mMapView.setTilesScaledToDpi(true);
        mMapView.getZoomController().setVisibility(CustomZoomButtonsController.Visibility.SHOW_AND_FADEOUT);


        // Add tiles layer with Custom Tile Source
        final MapTileProviderBasic tileProvider = new MapTileProviderBasic(getApplicationContext());

       // OSM日本
        final ITileSource tileSource = new XYTileSource("OSM Japan",  3, 18, 256, ".png",
                new String[] { "http://tile.openstreetmap.jp/" });

        tileProvider.setTileSource(tileSource);

        final TilesOverlay tilesOverlay = new TilesOverlay(tileProvider, this.getBaseContext());
        tilesOverlay.setLoadingBackgroundColor(Color.TRANSPARENT);
        mMapView.getOverlays().add(tilesOverlay);

スクリーンショット

右は、タイルを重ねる前の背景地図
左は、タイルを重ねた後の地図
4_base.png 4_jp.png

github にソースを公開した

2
3
0

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
2
3