#1929 - accessToken added as XML attribute option. Removed call to raw.txt for access token from MapFragment to test.

This commit is contained in:
Brad Leege
2015-07-24 14:36:57 -05:00
parent 2fd7a24576
commit d975d94de2
4 changed files with 19 additions and 21 deletions

View File

@@ -174,6 +174,9 @@ public class MapView extends SurfaceView {
if (typedArray.getString(R.styleable.MapView_styleUrl) != null) {
setStyleUrl(typedArray.getString(R.styleable.MapView_styleUrl));
}
if (typedArray.getString(R.styleable.MapView_accessToken) != null) {
setAccessToken(typedArray.getString(R.styleable.MapView_accessToken));
}
} finally {
typedArray.recycle();
}

View File

@@ -1,23 +1,14 @@
<resources>
<attr name="centerLongitude" format="float" />
<attr name="centerLatitude" format="float" />
<attr name="zoomLevel" format="float" />
<attr name="direction" format="float" />
<attr name="zoomEnabled" format="boolean" />
<attr name="scrollEnabled" format="boolean" />
<attr name="rotateEnabled" format="boolean" />
<attr name="debugActive" format="boolean" />
<attr name="styleUrl" format="string" />
<declare-styleable name="MapView">
<attr name="centerLongitude" />
<attr name="centerLatitude" />
<attr name="zoomLevel" />
<attr name="direction" />
<attr name="zoomEnabled" />
<attr name="scrollEnabled" />
<attr name="rotateEnabled" />
<attr name="debugActive" />
<attr name="styleUrl" />
<attr name="centerLongitude" format="float" />
<attr name="centerLatitude" format="float" />
<attr name="zoomLevel" format="float" />
<attr name="direction" format="float" />
<attr name="zoomEnabled" format="boolean" />
<attr name="scrollEnabled" format="boolean" />
<attr name="rotateEnabled" format="boolean" />
<attr name="debugActive" format="boolean" />
<attr name="styleUrl" format="string" />
<attr name="accessToken" format="string"/>
</declare-styleable>
</resources>

View File

@@ -44,6 +44,7 @@ public class MapFragment extends Fragment {
mMap = (MapView) inflater.inflate(R.layout.fragment_main, container, true);
// Load the access token
/*
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(getActivity().getApplicationContext().getResources().openRawResource(R.raw.token)));
String line = reader.readLine();
@@ -51,6 +52,7 @@ public class MapFragment extends Fragment {
} catch (IOException e) {
return null;
}
*/
// Need to pass on any saved state to the map
mMap.onCreate(savedInstanceState);

View File

@@ -1,4 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<com.mapbox.mapboxgl.views.MapView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" />
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>