pros and cons on mapquest android

210 views Asked by At

I have a requirement on building an android map app with options like markers, polyline, polygon and some click listeners. The app must not use google API and instead OSM data can be used. I have a custom tile server and looking for integrating it in the app. I came across Mapquest which similarly offers what i needed. All i have to know is whether i can integrate my own tile server with it or not. Any help will be appreciated

1

There are 1 answers

9
tony gil On

Mapquest integrates seemlessly as a basemap using OSMdroid. Having said that, it needs a key to work. Below is my basemap switcher (which receives an index for the basemap and switches accordingly). You may opt to switch between basemaps quite easily:

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;
}