mapquest android上的利弊

时间:2017-09-05 17:11:56

标签: java android openstreetmap mapquest

我需要构建一个Android地图应用程序,其中包含标记,折线,多边形和一些点击侦听器等选项。该应用不得使用谷歌API,而是可以使用OSM数据。我有一个自定义磁贴服务器,并希望将其集成到应用程序中。我遇到了Mapquest,它同样提供了我需要的东西。我必须知道的是我是否可以将自己的磁贴服务器与它集成。任何帮助将不胜感激

1 个答案:

答案 0 :(得分:2)

Mapquest使用OSMdroid无缝集成为底图。话虽如此,它需要一把钥匙才能工作。下面是我的底图切换器(它接收底图的索引并相应地切换)。您可以选择在底图之间轻松切换:

public boolean mapTileServerSwap() {
    boolean flagOK = false;
    String[] urlArray = {""};
    int mapTileServer = SessionPreferences.mapTileServer;
    switch (mapTileServer) {
        case(0):
        default:
            mapView.setTileSource(TileSourceFactory.DEFAULT_TILE_SOURCE);
            flagOK = true;
            break;
        case(1):
            urlArray[0] = "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/";
            mapView.setTileSource(new OnlineTileSourceBase("ArcGIS Online", null, 0, 18, 256, "",
                    urlArray) {
                @Override
                public String getTileURLString(MapTile aTile) {
                    String mImageFilenameEnding = ".png";
                    return getBaseUrl() + aTile.getZoomLevel() + "/" + aTile.getY() + "/" + aTile.getX()
                            + mImageFilenameEnding;
                }
            });
            flagOK = true;
            break;
        case(2):
            urlArray[0] = "http://basemap.nationalmap.gov/ArcGIS/rest/services/USGSTopo/MapServer/tile/";
            mapView.setTileSource(new OnlineTileSourceBase("USGS Topo", null, 0, 18, 256, "",
                    urlArray) {
                @Override
                public String getTileURLString(MapTile aTile) {
                    String mImageFilenameEnding = ".png";
                    return getBaseUrl() + aTile.getZoomLevel() + "/" + aTile.getY() + "/" + aTile.getX()
                            + mImageFilenameEnding;
                }
            });
            flagOK = true;
            break;
        case(3):
            mapView.setTileSource(TileSourceFactory.MAPQUESTAERIAL);
            flagOK = true;
            break;
        case(4):
            mapView.setTileSource(TileSourceFactory.MAPQUESTOSM);
            flagOK = true;
            break;
        case(5):
            //TODO 20160509
            // fix copyright and attributions for STAMEN!
            urlArray[0] = "http://a.tile.stamen.com/watercolor/";
            mapView.setTileSource(new XYTileSource("Stamen WaterColor", null, 0, 18, 256, ".jpg",
                    urlArray ));
            flagOK = true;
            break;
        case(6):
            urlArray[0] = "http://a.stamen.com/terrain/";
            mapView.setTileSource(new XYTileSource("Stamen Terrain", null, 0, 18, 256, ".jpg",
                    urlArray ));
            flagOK = true;
            break;
    }
    return flagOK;
}