1

I successfully integrated OpenStreetMap into my Android application using osmdroid and decided to try my hand at using OpenSeaMap as the map tile provider (the application is ocean-focussed).

Following the instructions outlined here for incorporating a custom tile provider into osmdroid I added the following code:

    // Create a custom tile source
    final IRegisterReceiver registerReceiver = new SimpleRegisterReceiver(context);
    final ITileSource tileSource = new XYTileSource("Mapnik", 
                                                    ResourceProxy.string.mapnik, 
                                                    1, 
                                                    18, 
                                                    256, 
                                                    ".png", 
                                                    new String[] {"http://tiles.openseamap.org/seamark/"});

    // Create a file cache modular provider
    final TileWriter tileWriter = new TileWriter();
    final MapTileFilesystemProvider fileSystemProvider = new MapTileFilesystemProvider(registerReceiver, tileSource);
    // Create a download modular tile provider
    final NetworkAvailabliltyCheck networkAvailabliltyCheck = new NetworkAvailabliltyCheck(context);
    final MapTileDownloader downloaderProvider = new MapTileDownloader(tileSource, tileWriter, networkAvailabliltyCheck);

    // Create a custom tile provider array with the custom tile source and the custom tile providers
    final MapTileProviderArray tileProviderArray = new MapTileProviderArray(tileSource, registerReceiver, new MapTileModuleProviderBase[] { fileSystemProvider, downloaderProvider });

    // Create the mapview with the custom tile provider array
    this.mapView = new MapView(context, 256, new DefaultResourceProxyImpl(context), tileProviderArray);

...notably, the code I've written excludes the GEMF file archive. To be honest, I don't understand the implications of this. Hopefully someone can shed some light on this topic as well. The effect of this is somewhat telling. Where OpenSeaMap information is provided a black tile is presented. Upon zooming in further, the tiles appear to be jumbled.

Black tiles where OpenSeaMap is adding content

As I continue to experiment, I noticed that sometimes, the OpenSeaMap data is rendered correctly;

Kind of working OpenSeaMap

Has anyone experienced similar issues with OpenSeaMap?

Surfer87
  • 21
  • 8
BrantApps
  • 6,362
  • 2
  • 27
  • 60
  • Are you aware of the fact that OpenSeaMap doesn't provide full tiles, but only overlays? You will always need another layer as the base layer. I'm not sure if this is supported by osmdroid. – scai May 20 '14 at 06:29
  • Hi @scai, having followed some links regarding how others have completed similar tasks, I arrived at this same conclusion. Unfortunately, the 'black tiles' result is still apparent when adding the OpenSeaMap overlay. I'm suspecting (owing to the sometimes working nature of the code I've written) that it may be a z-axis overlap problem/hardware acceleration problem. I'll keep you posted on anything new I find. Thank you for your comment. – BrantApps May 20 '14 at 08:34

1 Answers1

2

So, this was a bit of a two-fold thing, here is the code I'm running now;

// Create a custom tile source
final ITileSource seamarks = new XYTileSource("seamarks", 
                                              null, 
                                              0, 
                                              19, 
                                              256, 
                                              ".png", 
                                              new String[] {"http://tiles.openseamap.org/seamark/"});
final MapTileProviderBasic tileProvider = new MapTileProviderBasic(context, seamarks);
final TilesOverlay seamarksOverlay = new TilesOverlay(tileProvider, context);
seamarksOverlay.setLoadingBackgroundColor(Color.TRANSPARENT);
seamarksOverlay.setUseSafeCanvas(true);

// Create the mapview with the custom tile provider array
this.mapView = new MapView(context, 256);
this.mapView.setMultiTouchControls(true);
this.mapView.setUseSafeCanvas(true);
this.mapView.getOverlays().add(seamarksOverlay);

...the setLoadingBackgroundColor state helped to avoid the black tiles and a bit of patience allowed the overlay to be pulled down from the server, it's a bit slow!

BrantApps
  • 6,362
  • 2
  • 27
  • 60