My code is default codes. I am trying to use style from url. This is my json file link:
https://storage.googleapis.com/akfiha_public_img/localstyle.json
I want to add a new tile on my mpa but every time I get black screen. Actually I think there is a map on background cause when I add a marker, I can see the marker but the map isn't shown. I f I use normal default style like:
mapView.setStyleUrl(Style.MAPBOX_STREETS);
It is working for this option so I mean that my api key is working. But nevertheless I got this error:
E/mbgl: {Map}[ParseStyle]: Invalid glyph URL
A/libc: Fatal signal 6 (SIGABRT) at 0x00006a7e (code=-6), thread 27277 (com.test_mapbox)
E/mbgl: {Map}[Style]: Failed to load source simple-tiles:
E/mbgl: {Map}[Style]: Failed to load source simple-tiles:
Screenshot:
https://storage.googleapis.com/akfiha_public_img/screen1.jpg
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
import com.mapbox.mapboxsdk.constants.Style;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.views.MapView;
import java.io.IOException;
import java.io.InputStream;
public class MainActivity extends Activity {
private MapView mapView = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mapView = (MapView) findViewById(R.id.mapboxMapView);
mapView.setStyleUrl(Style.LIGHT);
mapView.addMarker(new MarkerOptions().position(new LatLng(40.73581, -73.99155)));
mapView.setCenterCoordinate(new LatLng(40.73581, -73.99155));
mapView.setZoomLevel(5);
mapView.onCreate(savedInstanceState);
}
@Override
protected void onStart() {
super.onStart();
mapView.onStart();
}
@Override
public void onResume() {
super.onResume();
mapView.onResume();
}
@Override
public void onPause() {
super.onPause();
mapView.onPause();
}
@Override
protected void onStop() {
super.onStop();
mapView.onStop();
}
@Override
protected void onDestroy() {
super.onDestroy();
mapView.onDestroy();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mapView.onSaveInstanceState(outState);
}
}
Manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="map.m_society.com.test_mapbox">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<com.mapbox.mapboxsdk.views.MapView
android:id="@+id/mapboxMapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
mapbox:access_token="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
/>
</RelativeLayout>
My gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "map.m_society.com.test_mapbox"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:3.2.0@aar'){
transitive=true
}
}
The "url" property for sources needs to point to a tileset URL. But mapbox://styles/cdagli/cikjdvql50063axkilqpnzhz9 is a _style_ URL. If you want to load the style "mapbox://styles/cdagli/cikjdvql50063axkilqpnzhz9", use:
mapView.setStyleUrl("mapbox://styles/cdagli/cikjdvql50063axkilqpnzhz9");
Can you give me an example for tileset url? Because I am getting that error:
could not be found or is an incompatible legacy map or style
Hi , i could not load my own tile source , with json styleurl , am getting below error log, can you please help me .
E/mbgl: {oxtovectortiles}[Style]: Failed to load tile 0/0/0=>0 for source mapbox: HTTP status code 400
Most helpful comment
Hi , i could not load my own tile source , with json styleurl , am getting below error log, can you please help me .
E/mbgl: {oxtovectortiles}[Style]: Failed to load tile 0/0/0=>0 for source mapbox: HTTP status code 400