OSM地图在android上看起来很乱

问题描述 投票:0回答:1

我试图在Android应用程序上加载OpenStreetMaps但地图无法正确加载。它们显示无序。

我正在使用一个自托管的地图服务器,它在浏览器中正确加载(用于演示的二手传单)。

代码如下,

public class MapActivity extends AppCompatActivity {

    final private int MIN_ZOOM_LEVEL = 3;
    final private int MAX_ZOOM_LEVEL = 18;
    final private int TILE_SIZE = 256;
    final private String IMAGE_EXTENSION = ".png";

    MapView map = null;

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

        //load/initialize the osmdroid configuration
        Context ctx = getApplicationContext();
        Configuration.getInstance().load(ctx, PreferenceManager.getDefaultSharedPreferences(ctx));

        setContentView(R.layout.activity_map);
        map = (MapView) findViewById(R.id.map);

        map.setTilesScaledToDpi(true);
        map.setMultiTouchControls(true);


        map.setTileSource(new OnlineTileSourceBase("Tiles", 2, 18, 256, ".png",
                new String[] { "http://maps.MY-DOMAIN.com/tile/" }) {
            @Override
            public String getTileURLString(long pMapTileIndex) {

                String url = getBaseUrl()
                        + MapTileIndex.getZoom(pMapTileIndex)
                        + "/" + MapTileIndex.getX(pMapTileIndex)
                        + "/" + MapTileIndex.getY(pMapTileIndex)
                        + mImageFilenameEnding;

                Log.e("MAP",url);
                return url;
            }
        });
    }
}

我最终得到的是,

enter image description here

我该如何解决这个问题?我已经看了一下文档,但没有提到这个。

android maps openstreetmap osmdroid
1个回答
2
投票

瓦片源是z / x / y vs z / y / x或者y坐标被反转,瓦片源更接近于TMS规范与打开街道地图使用的滑动地图格式。在任何一种情况下,请更正问题,清除磁贴缓存,然后再次尝试

© www.soinside.com 2019 - 2024. All rights reserved.