3

I am developing an android mapping app using OSMDroid. I am attempting to use free custom aerial imagery, completely independent of Google and/or Bing APIs. Please, do not propose any solution that uses their mapping APIs.

I have managed to display satellite imagery by including this code:

mapView.setTileSource(TileSourceFactory.MAPQUESTAERIAL);

but Tile Server does not offer tiling above 11 zoom and I need to get closer than that (say 15-16?).

Using ArcGIS tile server, I manage to display satellite imagery even to 16 layer zoom level, but tiles are shuffled around.

mapControl = (MapController) mapView.getController();
mapControl.setZoom(11);
String[] urlArray = {"http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/"};
mapView.setTileSource(new XYTileSource("ArcGisOnline", null, 0, 18, 256, ".png",urlArray ));

Basemap tiles are shuffled and do not correspond to lat/lon, but overlay is ok.

Basemap tiles are shuffled

1
  • 1
    tks 4 the tag approval and inclusion, @evilGenius!
    – tony gil
    Commented May 9, 2016 at 17:00

2 Answers 2

4

Marco_B pointed the way and, therefore his answer is accepted as correct.

Nevertheless, since it is a theoretical answer that takes time to figure out how to implement, i will post the final code using OSMdroid 4.3 (slight difference in 5.0, see Marco_B's answer):

String[] urlArray = {"http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/"};
mapView.setTileSource(new OnlineTileSourceBase("ARCGisOnline", 0, 18, 256, "", urlArray) {
       @Override
       public String getTileURLString(long pMapTileIndex) {
                String mImageFilenameEnding = ".png";
                return getBaseUrl() + MapTileIndex.getZoom(pMapTileIndex) + "/" 
                        + MapTileIndex.getY(pMapTileIndex) + "/" + MapTileIndex.getX(pMapTileIndex)
                        + mImageFilenameEnding;
       }
});

Make sure to verify @ArcGISOnline's terms of service before implementing this code commercially.

3

Using ArcGIS tile server, I manage to display satellite imagery even to 16 layer zoom level, but tiles are shuffled around. .... Basemap tiles are shuffled and do not correspond to lat/lon, but overlay is ok.

According to the osmdroid Map Sources page, ESRI map services use the ZYX URL tile numbering format instead of slippy maps' ZXY that osmdroid uses.

ZYX - Some map tile servers, such as some ESRI based products, use the Zoom/Y/X URL format. Since it's trivial to convert to ZXY, support for this format is easy to setup on osmdroid. We currently have at least one map source that uses this mechanism (see USGS maps).

Did you account for that? It would seem to explain your shuffled image... you need to convert according to the osmdroid GitHub page.

2
  • this seems like great help. will examine osmdroid github page. any further info is greatly appreciated. UPVOTED, pending final solution.
    – tony gil
    Commented May 8, 2016 at 10:14
  • you NAILED IT! I will post the precise code (some changes to demo code were necessary) as an additional answer, but this it. ACCEPTED answer.
    – tony gil
    Commented May 8, 2016 at 12:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.