How do I load my own tiles on MapBox?

101 Views Asked by At

How do I load my own tiles on MapBox? I am using setTileSource and somehow it does not seem to work.

My code looks something like this:

setContentView(R.layout.map);

mapview = (MapView) findViewById(R.id.mapview);
String tileServerBaseString = MyApp.myTileServerString();
tileServerBaseString = tileServerBaseString.replace("TYPE", "jpeg");
tileServerBaseString = tileServerBaseString.replace("Z", "{z}");
tileServerBaseString = tileServerBaseString.replace("X", "{x}");
tileServerBaseString = tileServerBaseString.replace("Y", "{y}");
IMapTileProviderCallback tileprovider = mapview.getTileProvider();
mapview.setTileSource(new WebSourceTileLayer("CustomTileLayer", tileServerBaseString));

and the view looks like this:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent">

<com.mapbox.mapboxsdk.views.MapView
    android:id="@+id/mapview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    mapbox:mapid="mapview"
    />

</LinearLayout>

Not sure what is the issue, any suggestions?

0

There are 0 best solutions below