Search code examples
androidmapboxopenmaptiles

how to use Openmap vector tiles with mapbox android Sdk


I am very new to Android development, but I managed to make bellow link work

https://www.mapbox.com/android-docs/map-sdk/overview/

Now I can load map by using mapbox API.

I just need one help , how can i use openmap vector tiles with this SDK, what do i need to change ?

I have installed vector tiles like this http://mydomain:9090/styles/osm-bright/?vector#8/22.615/90.344

I did not find any documentation for this Can any one please help me .


Solution

  • In order to use tiles hosted by a third-party, you need to set up a TileSet and then a VectorSource out of that set.

    TileSet tileSet = new TileSet("2.1.0", TILE_SET_URL);
    VectorSource source = new VectorSource(ID_SOURCE, tileSet);
    

    Also important to note is, that when using vector tiles you need to define a source layer.

    LineLayer lineLayer = new LineLayer(ID_LINE_LAYER, ID_SOURCE);
    lineLayer.setSourceLayer("source-layer");
    

    More on the source layer here, and a more elaborate example can be found in the Mapbox Demo App's repository.