0

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 .

Markus Kauppinen
  • 3,025
  • 4
  • 20
  • 30
alammd
  • 339
  • 4
  • 14

1 Answers1

1

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.

Łukasz Paczos
  • 597
  • 3
  • 9
  • Hi Lukasz, I am downloading the demo application to understand it better, regards to bellow line, in which files shall I put this under mapbox Android Sdk ? ( I am quite new .. may be asking very silly question ) TileSet tileSet = new TileSet("2.1.0", TILE_SET_URL); VectorSource source = new VectorSource(ID_SOURCE, tileSet); – alammd Jul 06 '18 at 10:11
  • Are you actually refer to this link https://www.mapbox.com/android-docs/map-sdk/overview/runtime-styling/ ? to add my own tiles from openmaptiles ? – alammd Jul 06 '18 at 11:20
  • Hi Lukasz, I manged to install the android demo code and I found the places you mentioned above to change tiles. now only question i have, i followed this url https://www.mapbox.com/android-docs/map-sdk/overview/, now my qustion is to make mobox sdk into my applicaton, do i need download the full code of SDK from git hub or can i not just use tileset and Vector source in my application which i created by using the above url ? Please let me know – alammd Jul 06 '18 at 15:26
  • Paczos, so I have done bellow TileSet tileSet = new TileSet("2.1.0", "http://192.168.1.7:9090/data/v3/{z}/{x}/{y}.pbf"); VectorSource source = new VectorSource("2.1.0", tileSet); now how do i replace mapbox api key with my tiles ? Mapbox.getInstance(this, "xxxxxx"); or am I doing totally wrong ? please help me with this. – alammd Jul 06 '18 at 16:26
  • Paczos, I think i am getting it now , here its saying how to add source and layer, https://www.mapbox.com/help/android-dds-circle-layer/#add-a-source-and-a-circle-layer Now i have 2 question , Please help me with , i am running openmaptiles which is running on http://mydomain:9090/styles/osm-bright/?vector#8/22.615/90.344 in this case , what will be the right parameter for openmaptiles ? I dont see too much information about it in openmaptiles. how can i set it as per Openmaptiles hosted in port 9090 ? I guess that will solve my problem, Thanks for the help – alammd Jul 06 '18 at 18:53
  • i did bellow but it crashed , please help me on this public void onMapReady(final MapboxMap mapboxMap) { VectorSource vectorSource = new VectorSource( "openmaptiles", "http://public:9090/styles/osm-bright/{z}/{x}/{y}.png" ); mapboxMap.addSource(vectorSource); LineLayer lineLayer = new LineLayer("park_outline", "openmaptiles" ); lineLayer.setSourceLayer("park"); mapboxMap.addLayer(lineLayer); – alammd Jul 06 '18 at 19:41
  • Please follow https://www.mapbox.com/help/first-steps-android-sdk/ if you have questions regarding initial map setup. – Łukasz Paczos Jul 16 '18 at 07:45