首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Mapbox中的Nutiteq加载Mbtiles

使用Mapbox中的Nutiteq加载Mbtiles
EN

Stack Overflow用户
提问于 2015-09-30 08:16:10
回答 1查看 579关注 0票数 1

我正在研究如何使用nutiteq从mapbox加载mbtiles。我知道如何使用以下代码脱机加载mbtiles。

代码语言:javascript
复制
// 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直接从mbtiles url加载它?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-10-01 13:50:02

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

我可以想到下面的MapBox URL:

a.关于MapBox as online raster源代码,请参阅https://developer.nutiteq.com/guides/raster-tile-sources

对于MapBox作为online向量源,您还需要定义样式,它需要更多的编码:

代码语言:javascript
复制
    // 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);

    }
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32861155

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档