1

我正在研究使用 nutiteq SDK 从 mapbox 加载 mbtiles 的方法。我知道如何使用此代码离线加载 mbtiles

// 1. Create tile data source from mbtiles file
MBTilesTileDataSource tileDataSource = new MBTilesTileDataSource("/sdcard/estonia_ntvt.mbtiles");

// 2. Load vector tile styleset
UnsignedCharVector styleBytes = AssetUtils.loadBytes("osmbright.zip");
MBVectorTileStyleSet vectorTileStyleSet = new MBVectorTileStyleSet(styleBytes);

// 3. Create vector tile decoder using the styleset
VectorTileDecoder vectorTileDecoder = new MBVectorTileDecoder(vectorTileStyleSet);

// 4. Create vector tile layer, using previously created data source and decoder
TileLayer vectorTileLayer = new VectorTileLayer(tileDataSource, vectorTileDecoder);

// 5. Add vector tile layer
mapView.getLayers().add(vectorTileLayer);

有没有办法使用 Nutiteq SDK 直接从 mapbox mbtiles url 加载它?

4

1 回答 1

1

“mapbox mbtiles url”是什么意思,你能举个例子吗?mbtiles是指离线包吗?

我可以想到以下 MapBox URL:

一种。对于 MapBox 作为在线栅格源,请参阅https://developer.nutiteq.com/guides/raster-tile-sources

湾。对于 MapBox 作为在线矢量源,您还需要定义样式,并且需要更多编码:

    // load style file from assets. Nutiteq style is quite well compatible with MapBox Streets, 
    //   even though NT vector tiles are a bit different
    UnsignedCharVector styleBytes = AssetUtils.loadBytes("nutibright-v2.zip");
    if (styleBytes != null){

        // Create style set
        MBVectorTileStyleSet vectorTileStyleSet = new MBVectorTileStyleSet(styleBytes);
        MBVectorTileDecoder vectorTileDecoder = new MBVectorTileDecoder(vectorTileStyleSet);

        // Create tile data source and layer for vector tiles
        TileDataSource vectorTileDataSource = new HTTPTileDataSource(0, 14, "http://a.tiles.mapbox.com/v4/mapbox.mapbox-streets-v5/{zoom}/{x}/{y}.vector.pbf?access_token=pk...YOUR-MAPBOX-KEY");
        VectorTileLayer baseLayer = new VectorTileLayer(vectorTileDataSource, vectorTileDecoder);

        // add layer to map
        mapView.getLayers().add(baseLayer);

    }
于 2015-10-01T13:50:02.373 回答