I create my .mbtiles following this steps
- I use osm-carto style and sources from geofabrik the create my map
- I use Kosmtik editor to see the map and a plugin(kosmtik-mbtiles-exporter) to export the .mbtiles
this is my swift code to load my bundle .mbtiles file
override func viewDidLoad() {
super.viewDidLoad()
map = NTMapView()
map.frame = view.bounds
//Need to add as a subview,
view.addSubview(map)
// Get base projection from mapView
let projection = map.getOptions().getBaseProjection();
// Create a local vector data source
let source: NTTileDataSource? = createTileDataSource()
let baseLayer = NTCartoOnlineVectorTileLayer(style: .CARTO_BASEMAP_STYLE_VOYAGER)
let decoder: NTVectorTileDecoder? = baseLayer?.getTileDecoder()
let layer = NTVectorTileLayer(dataSource: source, decoder: decoder)
map?.getLayers()?.add(layer)
map.getOptions().setPanningMode(NTPanningMode.PANNING_MODE_STICKY)
}
func createTileDataSource() -> NTTileDataSource {
let name: String = "cuba.output"
let format : String = "mbtiles"
// file-based local offline datasource
let source: String? = Bundle.main.path(forResource: name, ofType: format)
let vectorTileDataSource: NTTileDataSource? = NTMBTilesTileDataSource(minZoom: 0, maxZoom: 14, path: source)
return vectorTileDataSource!
}}
But when run the app give me this error
Sep 18 12:53:00 WeGoCuba[1547] : MBTilesTileDataSource::loadTile: Loading MapTile [x=0, y=0, zoom=0, frameNr=0, id=0]
Sep 18 12:53:00 WeGoCuba[1547] : MBVectorTileDecoder::decodeTile: Exception while decoding: unknown pbf type
Sep 18 12:53:00 WeGoCuba[1547] : VectorTileLayer::FetchTask:Failed to decode tile
Why is give me this error? Is the .mbtiles file wrong? If so you could give the steps to create a correct one?
It seems that with kosmtik you get raster mbtiles, not vector ones. These can be added to the map easily with following, but these are pre-styled as any raster datasource would be.