This is a static archive of our old OSM Help Site. Please post any new questions and answers at community.openstreetmap.org.

Using osmdroid for custom map images and not osm data

0

Can I use the osmdroid library to display my own map. The folder structure looks the following

mapname (folder)
 |-zoomlevel (folder)
   |- X_Y.png (a lot of images)

I thought I could load the tiles using a custom source but it seems nothing that I do works

mResourceProxy = new DefaultResourceProxyImpl(getApplicationContext());

// Add tiles layer with custom tile source

final MapView mapView = new MapView( this, 256 );

final ITileSource tileSource = new TileSource(Environment.getDataDirectory().getPath() + "/exampleapp/mymap", null);
mapView.setTileSource(tileSource);

mapView.setMultiTouchControls(true);

setContentView(mapView);
mMapView = mapView;

mMapView.getController().setZoom(5);

And my custom source

public class TileSource extends BitmapTileSourceBase{

    public TileSource(String aName, string aResourceId) {

        super(aName, aResourceId, 1, 6, 256, ".png");
    }

    @Override
    public String getTileRelativeFilenameString(MapTile tile) {
        final StringBuilder sb = new StringBuilder();
        sb.append(pathBase());
        sb.append('/');
        sb.append(tile.getZoomLevel());
        sb.append('/');
        sb.append(tile.getX());
        sb.append('_');
        sb.append(tile.getY());
        sb.append(imageFilenameEnding());
        return sb.toString();

    }
}

asked 17 Feb '13, 00:12

Bartinger's gravatar image

Bartinger
11112
accept rate: 0%