[android] - remove style config from mapboxMapOptions and attributes

This commit is contained in:
tobrun
2018-12-10 15:37:51 +01:00
committed by Tobrun
parent 16aa48151c
commit cbcd0875e3
73 changed files with 218 additions and 267 deletions

View File

@@ -92,8 +92,6 @@ public final class MapboxMap {
// Map configuration
setDebugActive(options.getDebugActive());
setApiBaseUrl(options);
setStyleUrl(options);
setStyleJson(options);
setPrefetchesTiles(options);
}
@@ -851,25 +849,6 @@ public final class MapboxMap {
});
}
/**
* Loads a new map style from MapboxMapOptions if available.
*
* @param options the object containing the style url
*/
private void setStyleUrl(@NonNull MapboxMapOptions options) {
String style = options.getStyleUrl();
if (!TextUtils.isEmpty(style)) {
setStyle(new Style.Builder().fromUrl(style));
}
}
private void setStyleJson(@NonNull MapboxMapOptions options) {
String styleJson = options.getStyleJson();
if (!TextUtils.isEmpty(styleJson)) {
setStyle(new Style.Builder().fromJson(styleJson));
}
}
//
// Annotations
//
@@ -1839,7 +1818,7 @@ public final class MapboxMap {
/**
* Returns the {@link LocationComponent} that can be used to display user's location on the map.
* <p>
* Use {@link LocationComponent#activateLocationComponent(Context)} or any overload to activate the component,
* Use {@link LocationComponent#activateLocationComponent(Context, Style)} or any overload to activate the component,
* then, enable it with {@link LocationComponent#setLocationComponentEnabled(boolean)}.
* <p>
* You can customize the location icon and more with {@link com.mapbox.mapboxsdk.location.LocationComponentOptions}.

View File

@@ -77,9 +77,6 @@ public class MapboxMapOptions implements Parcelable {
@ColorInt
private int foregroundLoadColor;
private String styleUrl;
private String styleJson;
private float pixelRatio;
private boolean crossSourceCollisions = true;
@@ -122,8 +119,6 @@ public class MapboxMapOptions implements Parcelable {
zoomGesturesEnabled = in.readByte() != 0;
doubleTapGesturesEnabled = in.readByte() != 0;
styleUrl = in.readString();
styleJson = in.readString();
apiBaseUrl = in.readString();
textureMode = in.readByte() != 0;
translucentTextureSurface = in.readByte() != 0;
@@ -149,8 +144,6 @@ public class MapboxMapOptions implements Parcelable {
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.mapbox_MapView, 0, 0);
try {
mapboxMapOptions.camera(new CameraPosition.Builder(typedArray).build());
mapboxMapOptions.styleUrl(typedArray.getString(R.styleable.mapbox_MapView_mapbox_styleUrl));
mapboxMapOptions.styleJson(typedArray.getString(R.styleable.mapbox_MapView_mapbox_styleJson));
mapboxMapOptions.apiBaseUrl(typedArray.getString(R.styleable.mapbox_MapView_mapbox_apiBaseUrl));
mapboxMapOptions.zoomGesturesEnabled(
@@ -266,30 +259,6 @@ public class MapboxMapOptions implements Parcelable {
return this;
}
/**
* Specifies the styleUrl url associated with a map view.
*
* @param styleUrl Url to be used to load a styleUrl
* @return This
*/
@NonNull
public MapboxMapOptions styleUrl(String styleUrl) {
this.styleUrl = styleUrl;
return this;
}
/**
* Specifies the styleJson associated with a map view.
*
* @param styleJson json to used as style
* @return This
*/
@NonNull
public MapboxMapOptions styleJson(String styleJson) {
this.styleJson = styleJson;
return this;
}
/**
* Specifies the used debug type for a map view.
*
@@ -776,24 +745,6 @@ public class MapboxMapOptions implements Parcelable {
return logoMargins;
}
/**
* Get the current configured styleUrl url for a map view.
*
* @return Style url to be used.
*/
public String getStyleUrl() {
return styleUrl;
}
/**
* Get the current configured styleJson for a map view.
*
* @return Style json to be used.
*/
public String getStyleJson() {
return styleJson;
}
/**
* Get the current configured rotate gesture state for a map view.
*
@@ -972,8 +923,6 @@ public class MapboxMapOptions implements Parcelable {
dest.writeByte((byte) (zoomGesturesEnabled ? 1 : 0));
dest.writeByte((byte) (doubleTapGesturesEnabled ? 1 : 0));
dest.writeString(styleUrl);
dest.writeString(styleJson);
dest.writeString(apiBaseUrl);
dest.writeByte((byte) (textureMode ? 1 : 0));
dest.writeByte((byte) (translucentTextureSurface ? 1 : 0));
@@ -1061,13 +1010,6 @@ public class MapboxMapOptions implements Parcelable {
if (!Arrays.equals(attributionMargins, options.attributionMargins)) {
return false;
}
if (styleUrl != null ? !styleUrl.equals(options.styleUrl) : options.styleUrl != null) {
return false;
}
if (styleJson != null ? !styleJson.equals(options.styleJson) : options.styleJson != null) {
return false;
}
if (apiBaseUrl != null ? !apiBaseUrl.equals(options.apiBaseUrl) : options.apiBaseUrl != null) {
return false;
@@ -1122,8 +1064,6 @@ public class MapboxMapOptions implements Parcelable {
result = 31 * result + (apiBaseUrl != null ? apiBaseUrl.hashCode() : 0);
result = 31 * result + (textureMode ? 1 : 0);
result = 31 * result + (translucentTextureSurface ? 1 : 0);
result = 31 * result + (styleUrl != null ? styleUrl.hashCode() : 0);
result = 31 * result + (styleJson != null ? styleJson.hashCode() : 0);
result = 31 * result + (prefetchesTiles ? 1 : 0);
result = 31 * result + (zMediaOverlay ? 1 : 0);
result = 31 * result + (localIdeographFontFamily != null ? localIdeographFontFamily.hashCode() : 0);

View File

@@ -9,8 +9,6 @@
<!-- Exposed attrs.xml -->
<!--Configuration-->
<public name="mapbox_styleUrl" type="attr" />
<public name="mapbox_styleJson" type="attr" />
<public name="mapbox_apiBaseUrl" type="attr" />
<public name="mapbox_localIdeographFontFamily" type="attr" />
<public name="mapbox_cross_source_collisions" type="attr" />

View File

@@ -3,8 +3,6 @@
<declare-styleable name="mapbox_MapView">
<!--Configuration-->
<attr name="mapbox_styleUrl" format="string"/>
<attr name="mapbox_styleJson" format="string"/>
<attr name="mapbox_apiBaseUrl" format="string"/>
<attr name="mapbox_localIdeographFontFamily" format="string"/>
<attr name="mapbox_cross_source_collisions" format="boolean"/>

View File

@@ -145,13 +145,6 @@ public class MapboxMapOptionsTest {
assertFalse(new MapboxMapOptions().rotateGesturesEnabled(false).getRotateGesturesEnabled());
}
@Test
public void testStyleUrl() {
assertEquals(Style.DARK, new MapboxMapOptions().styleUrl(Style.DARK).getStyleUrl());
assertNotEquals(Style.LIGHT, new MapboxMapOptions().styleUrl(Style.DARK).getStyleUrl());
assertNull(new MapboxMapOptions().getStyleUrl());
}
@Test
public void testCamera() {
CameraPosition position = new CameraPosition.Builder().build();

View File

@@ -77,6 +77,7 @@ public class AnimatedSymbolLayerActivity extends AppCompatActivity {
mapView.getMapAsync(map -> {
this.mapboxMap = map;
map.setStyle(Style.MAPBOX_STREETS, style -> {
this.style = style;
setupCars();
animateRandomRoutes();
animateTaxi();
@@ -184,7 +185,7 @@ public class AnimatedSymbolLayerActivity extends AppCompatActivity {
}
private void updatePassengerSource() {
GeoJsonSource source = mapboxMap.getStyle().getSourceAs(PASSENGER_SOURCE);
GeoJsonSource source = style.getSourceAs(PASSENGER_SOURCE);
FeatureCollection featureCollection = FeatureCollection.fromFeatures(new Feature[] {
Feature.fromGeometry(
Point.fromLngLat(
@@ -261,7 +262,7 @@ public class AnimatedSymbolLayerActivity extends AppCompatActivity {
randomCarSource = new GeoJsonSource(RANDOM_CAR_SOURCE, featuresFromRoutes());
style.addSource(randomCarSource);
mapboxMap.getStyle().addImage(RANDOM_CAR_IMAGE_ID,
style.addImage(RANDOM_CAR_IMAGE_ID,
((BitmapDrawable) getResources().getDrawable(R.drawable.ic_car_top)).getBitmap());
SymbolLayer symbolLayer = new SymbolLayer(RANDOM_CAR_LAYER, RANDOM_CAR_SOURCE);
@@ -286,7 +287,7 @@ public class AnimatedSymbolLayerActivity extends AppCompatActivity {
)
});
mapboxMap.getStyle().addImage(PASSENGER,
style.addImage(PASSENGER,
((BitmapDrawable) getResources().getDrawable(R.drawable.icon_burned)).getBitmap());
GeoJsonSource geoJsonSource = new GeoJsonSource(PASSENGER_SOURCE, featureCollection);
@@ -312,7 +313,7 @@ public class AnimatedSymbolLayerActivity extends AppCompatActivity {
FeatureCollection featureCollection = FeatureCollection.fromFeatures(new Feature[] {feature});
taxi = new Car(feature, passenger, getDuration());
mapboxMap.getStyle().addImage(TAXI,
style.addImage(TAXI,
((BitmapDrawable) getResources().getDrawable(R.drawable.ic_taxi_top)).getBitmap());
taxiSource = new GeoJsonSource(TAXI_SOURCE, featureCollection);
style.addSource(taxiSource);

View File

@@ -11,13 +11,14 @@ import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.utils.GeoParseUtil;
import timber.log.Timber;
import java.io.IOException;
import java.lang.ref.WeakReference;
@@ -26,8 +27,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import timber.log.Timber;
/**
* Test activity showcasing adding a large amount of Markers.
*/
@@ -43,9 +42,14 @@ public class BulkMarkerActivity extends AppCompatActivity implements AdapterView
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_marker_bulk);
mapView = (MapView) findViewById(R.id.mapView);
mapView = findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(mapboxMap -> BulkMarkerActivity.this.mapboxMap = mapboxMap);
mapView.getMapAsync(this::initMap);
}
private void initMap(MapboxMap mapboxMap) {
this.mapboxMap = mapboxMap;
mapboxMap.setStyle(Style.MAPBOX_STREETS);
}
@Override

View File

@@ -58,7 +58,6 @@ public class PolygonActivity extends AppCompatActivity implements OnMapReadyCall
MapboxMapOptions options = new MapboxMapOptions()
.attributionTintColor(RED_COLOR)
.compassFadesWhenFacingNorth(false)
.styleUrl(Style.MAPBOX_STREETS)
.camera(new CameraPosition.Builder()
.target(new LatLng(45.520486, -122.673541))
.zoom(12)
@@ -77,6 +76,7 @@ public class PolygonActivity extends AppCompatActivity implements OnMapReadyCall
@Override
public void onMapReady(@NonNull MapboxMap map) {
mapboxMap = map;
map.setStyle(Style.MAPBOX_STREETS);
map.setOnPolygonClickListener(polygon -> Toast.makeText(
PolygonActivity.this,

View File

@@ -13,6 +13,7 @@ import com.mapbox.mapboxsdk.annotations.PolylineOptions;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.testapp.R;
import java.util.ArrayList;
@@ -61,11 +62,11 @@ public class PolylineActivity extends AppCompatActivity {
polylineOptions.addAll(getAllPolylines());
}
mapView = (MapView) findViewById(R.id.mapView);
mapView = findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(mapboxMap -> {
PolylineActivity.this.mapboxMap = mapboxMap;
mapboxMap.setStyle(Style.SATELLITE_STREETS);
mapboxMap.setOnPolylineClickListener(polyline -> Toast.makeText(
PolylineActivity.this,
"You clicked on polyline with id = " + polyline.getId(),

View File

@@ -11,6 +11,7 @@ import com.mapbox.mapboxsdk.annotations.MarkerOptions;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.testapp.R;
import java.text.DecimalFormat;
@@ -53,6 +54,8 @@ public class PressForMarkerActivity extends AppCompatActivity {
return false;
});
mapboxMap.setStyle(Style.MAPBOX_STREETS);
if (savedInstanceState != null) {
markerList = savedInstanceState.getParcelableArrayList(STATE_MARKER_LIST);
if (markerList != null) {

View File

@@ -24,6 +24,7 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.testapp.R;
/**
@@ -81,6 +82,7 @@ public class CameraAnimatorActivity extends AppCompatActivity implements OnMapRe
@Override
public void onMapReady(@NonNull final MapboxMap map) {
mapboxMap = map;
map.setStyle(Style.MAPBOX_STREETS);
initFab();
}

View File

@@ -20,6 +20,7 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.testapp.R;
import timber.log.Timber;
@@ -44,7 +45,7 @@ public class CameraPositionActivity extends FragmentActivity implements OnMapRea
toolbar.setNavigationIcon(R.drawable.ic_ab_back);
toolbar.setNavigationOnClickListener(v -> finish());
mapView = (MapView) findViewById(R.id.mapView);
mapView = findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(this);
}
@@ -52,12 +53,14 @@ public class CameraPositionActivity extends FragmentActivity implements OnMapRea
@Override
public void onMapReady(@NonNull final MapboxMap map) {
mapboxMap = map;
toggleLogCameraChanges();
map.setStyle(Style.SATELLITE_STREETS, style -> {
// add a listener to FAB
fab = findViewById(R.id.fab);
fab.setColorFilter(ContextCompat.getColor(CameraPositionActivity.this, R.color.primary));
fab.setOnClickListener(this);
});
// add a listener to FAB
fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setColorFilter(ContextCompat.getColor(CameraPositionActivity.this, R.color.primary));
fab.setOnClickListener(this);
toggleLogCameraChanges();
// listen to long click events to toggle logging camera changes
mapboxMap.addOnMapLongClickListener(this);

View File

@@ -40,14 +40,13 @@ public class MaxMinZoomActivity extends AppCompatActivity implements OnMapReadyC
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(this);
mapView.addOnDidFinishLoadingStyleListener(() -> {
Timber.d("Style Loaded");
});
mapView.addOnDidFinishLoadingStyleListener(() -> Timber.d("Style Loaded"));
}
@Override
public void onMapReady(@NonNull final MapboxMap map) {
mapboxMap = map;
mapboxMap.setStyle(Style.MAPBOX_STREETS);
mapboxMap.setMinZoomPreference(3);
mapboxMap.setMaxZoomPreference(5);
mapboxMap.addOnMapClickListener(clickListener);

View File

@@ -15,6 +15,7 @@ import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.maps.UiSettings;
import com.mapbox.mapboxsdk.testapp.R;
@@ -61,6 +62,8 @@ public class ScrollByActivity extends AppCompatActivity implements OnMapReadyCal
@Override
public void onMapReady(@NonNull MapboxMap map) {
mapboxMap = map;
mapboxMap.setStyle(Style.DARK);
UiSettings uiSettings = mapboxMap.getUiSettings();
uiSettings.setLogoEnabled(false);
uiSettings.setAttributionEnabled(false);

View File

@@ -7,6 +7,7 @@ import android.support.v7.app.AppCompatActivity;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.testapp.R;
/**
@@ -23,14 +24,16 @@ public class EspressoTestActivity extends AppCompatActivity implements OnMapRead
setContentView(R.layout.activity_espresso_test);
// Initialize map as normal
mapView = (MapView) findViewById(R.id.mapView);
mapView = findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(this);
}
@Override
public void onMapReady(@NonNull MapboxMap map) {
mapboxMap = map;
public void onMapReady(@NonNull final MapboxMap map) {
map.setStyle(new Style.Builder().fromUrl("asset://streets.json"),
style -> mapboxMap = map
);
}
public MapboxMap getMapboxMap() {

View File

@@ -18,6 +18,7 @@ import com.mapbox.mapboxsdk.annotations.Marker;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.testapp.R;
@@ -70,13 +71,15 @@ public class QueryRenderedFeaturesPropertiesActivity extends AppCompatActivity {
mapView = (MapView) findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(mapboxMap -> {
QueryRenderedFeaturesPropertiesActivity.this.mapboxMap = mapboxMap;
mapboxMap.setStyle(Style.MAPBOX_STREETS, style -> {
QueryRenderedFeaturesPropertiesActivity.this.mapboxMap = mapboxMap;
// Add custom window adapter
addCustomInfoWindowAdapter(mapboxMap);
// Add custom window adapter
addCustomInfoWindowAdapter(mapboxMap);
// Add a click listener
mapboxMap.addOnMapClickListener(mapClickListener);
// Add a click listener
mapboxMap.addOnMapClickListener(mapClickListener);
});
});
}

View File

@@ -44,7 +44,6 @@ public class MapFragmentActivity extends AppCompatActivity implements MapFragmen
private MapboxMapOptions createFragmentOptions() {
MapboxMapOptions options = new MapboxMapOptions();
options.styleUrl(Style.OUTDOORS);
options.scrollGesturesEnabled(false);
options.zoomGesturesEnabled(false);
@@ -72,6 +71,7 @@ public class MapFragmentActivity extends AppCompatActivity implements MapFragmen
@Override
public void onMapReady(@NonNull MapboxMap map) {
mapboxMap = map;
mapboxMap.setStyle(Style.OUTDOORS);
}
@Override

View File

@@ -1,8 +1,10 @@
package com.mapbox.mapboxsdk.testapp.activity.fragment;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.maps.SupportMapFragment;
import com.mapbox.mapboxsdk.testapp.R;
/**
@@ -14,5 +16,16 @@ public class MultiMapActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_multi_map);
FragmentManager fragmentManager = getSupportFragmentManager();
initFragmentStyle(fragmentManager, R.id.map1, Style.MAPBOX_STREETS);
initFragmentStyle(fragmentManager, R.id.map2, Style.LIGHT);
initFragmentStyle(fragmentManager, R.id.map3, Style.SATELLITE_STREETS);
initFragmentStyle(fragmentManager, R.id.map4, Style.DARK);
}
private void initFragmentStyle(FragmentManager fragmentManager, int fragmentId, String styleId) {
((SupportMapFragment) fragmentManager.findFragmentById(fragmentId))
.getMapAsync(mapboxMap -> mapboxMap.setStyle(styleId));
}
}

View File

@@ -16,6 +16,7 @@ import android.widget.TextView
import com.mapbox.mapboxsdk.camera.CameraPosition
import com.mapbox.mapboxsdk.geometry.LatLng
import com.mapbox.mapboxsdk.maps.MapboxMapOptions
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback
import com.mapbox.mapboxsdk.maps.Style
import com.mapbox.mapboxsdk.maps.SupportMapFragment
import com.mapbox.mapboxsdk.testapp.R
@@ -113,26 +114,27 @@ class NestedViewPagerActivity : AppCompatActivity() {
options.zoomGesturesEnabled(false)
when (position) {
0 -> {
options.styleUrl(Style.MAPBOX_STREETS)
options.camera(CameraPosition.Builder().target(LatLng(34.920526, 102.634774)).zoom(3.0).build())
return SupportMapFragment.newInstance(options)
val fragment = SupportMapFragment.newInstance(options)
fragment.getMapAsync { mapboxMap -> mapboxMap.setStyle(Style.MAPBOX_STREETS) }
return fragment
}
1 -> {
return EmptyFragment.newInstance()
}
2 -> {
options.styleUrl(Style.DARK)
options.camera(CameraPosition.Builder().target(LatLng(62.326440, 92.764913)).zoom(3.0).build())
return SupportMapFragment.newInstance(options)
}
val fragment = SupportMapFragment.newInstance(options)
fragment.getMapAsync { mapboxMap -> mapboxMap.setStyle(Style.DARK) }
return fragment }
3 -> {
return EmptyFragment.newInstance()
}
4 -> {
options.styleUrl(Style.SATELLITE)
options.camera(CameraPosition.Builder().target(LatLng(-25.007786, 133.623852)).zoom(3.0).build())
return SupportMapFragment.newInstance(options)
}
val fragment = SupportMapFragment.newInstance(options)
fragment.getMapAsync { mapboxMap -> mapboxMap.setStyle(Style.SATELLITE) }
return fragment }
5 -> {
return EmptyFragment.newInstance()
}

View File

@@ -45,7 +45,6 @@ public class SupportMapFragmentActivity extends AppCompatActivity implements Map
private MapboxMapOptions createFragmentOptions() {
MapboxMapOptions options = new MapboxMapOptions();
options.styleUrl(Style.MAPBOX_STREETS);
options.scrollGesturesEnabled(false);
options.zoomGesturesEnabled(false);
@@ -73,6 +72,7 @@ public class SupportMapFragmentActivity extends AppCompatActivity implements Map
@Override
public void onMapReady(@NonNull MapboxMap map) {
mapboxMap = map;
mapboxMap.setStyle(Style.SATELLITE);
}
@Override

View File

@@ -6,11 +6,10 @@ import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapboxMapOptions;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.maps.SupportMapFragment;
import com.mapbox.mapboxsdk.testapp.R;
@@ -52,19 +51,25 @@ public class ViewPagerActivity extends AppCompatActivity {
switch (position) {
case 0:
options.styleUrl(Style.MAPBOX_STREETS);
options.camera(new CameraPosition.Builder().target(new LatLng(34.920526, 102.634774)).zoom(3).build());
fragment = SupportMapFragment.newInstance(options);
fragment.getMapAsync(mapboxMap -> {
mapboxMap.setStyle(Style.MAPBOX_STREETS);
});
break;
case 1:
options.styleUrl(Style.DARK);
options.camera(new CameraPosition.Builder().target(new LatLng(62.326440, 92.764913)).zoom(3).build());
fragment = SupportMapFragment.newInstance(options);
fragment.getMapAsync(mapboxMap -> {
mapboxMap.setStyle(Style.DARK);
});
break;
case 2:
options.styleUrl(Style.SATELLITE);
options.camera(new CameraPosition.Builder().target(new LatLng(-25.007786, 133.623852)).zoom(3).build());
fragment = SupportMapFragment.newInstance(options);
fragment.getMapAsync(mapboxMap -> {
mapboxMap.setStyle(Style.SATELLITE);
});
break;
}
return fragment;

View File

@@ -5,9 +5,9 @@ import android.os.Bundle;
import android.support.v4.print.PrintHelper;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.testapp.R;
/**
@@ -25,18 +25,23 @@ public class PrintActivity extends AppCompatActivity implements MapboxMap.Snapsh
mapView = findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(mapboxMap -> PrintActivity.this.mapboxMap = mapboxMap);
mapView.getMapAsync(this::initMap);
final View fab = findViewById(R.id.fab);
if (fab != null) {
fab.setOnClickListener(view -> {
if (mapboxMap.getStyle() != null) {
if (mapboxMap != null && mapboxMap.getStyle() != null) {
mapboxMap.snapshot(PrintActivity.this);
}
});
}
}
private void initMap(MapboxMap mapboxMap) {
this.mapboxMap = mapboxMap;
mapboxMap.setStyle(Style.MAPBOX_STREETS);
}
@Override
public void onSnapshotReady(Bitmap snapshot) {
PrintHelper photoPrinter = new PrintHelper(this);

View File

@@ -13,6 +13,7 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.testapp.R;
import java.text.DecimalFormat;
@@ -63,8 +64,10 @@ public class InfoWindowActivity extends AppCompatActivity
@Override
public void onMapReady(@NonNull MapboxMap mapboxMap) {
this.mapboxMap = mapboxMap;
addMarkers();
addInfoWindowListeners();
mapboxMap.setStyle(Style.MAPBOX_STREETS, style -> {
addMarkers();
addInfoWindowListeners();
});
}
private void addMarkers() {

View File

@@ -12,6 +12,7 @@ import com.mapbox.mapboxsdk.annotations.Marker;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.model.annotations.CityStateMarker;
import com.mapbox.mapboxsdk.testapp.model.annotations.CityStateMarkerOptions;
@@ -30,12 +31,14 @@ public class InfoWindowAdapterActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_infowindow_adapter);
mapView = (MapView) findViewById(R.id.mapView);
mapView = findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(map -> {
mapboxMap = map;
addMarkers();
addCustomInfoWindowAdapter();
map.setStyle(Style.MAPBOX_STREETS, style -> {
addMarkers();
addCustomInfoWindowAdapter();
});
});
}

View File

@@ -80,7 +80,6 @@ public class LocationMapChangeActivity extends AppCompatActivity implements OnMa
@SuppressLint("MissingPermission")
private void activateLocationComponent(@NonNull Style style) {
LocationComponent locationComponent = mapboxMap.getLocationComponent();
locationComponent.onStart();
locationComponent.activateLocationComponent(this, style);
locationComponent.setLocationComponentEnabled(true);
locationComponent.setRenderMode(RenderMode.COMPASS);

View File

@@ -12,7 +12,6 @@ import android.view.MenuItem;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Toast;
import com.mapbox.android.core.location.LocationEngineRequest;
import com.mapbox.android.core.permissions.PermissionsListener;
import com.mapbox.android.core.permissions.PermissionsManager;
@@ -123,7 +122,7 @@ public class LocationModesActivity extends AppCompatActivity implements OnMapRea
public void onMapReady(@NonNull MapboxMap mapboxMap) {
this.mapboxMap = mapboxMap;
mapboxMap.getStyle(style -> {
mapboxMap.setStyle(Style.MAPBOX_STREETS, style -> {
int[] padding;
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
padding = new int[] {0, 750, 0, 0};

View File

@@ -15,14 +15,13 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.MapboxMapOptions;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.utils.MapFragmentUtils;
@@ -131,8 +130,10 @@ public class BottomSheetActivity extends AppCompatActivity {
public static MainMapFragment newInstance(int mapCounter) {
MainMapFragment mapFragment = new MainMapFragment();
Bundle bundle = new Bundle();
bundle.putInt("mapcounter", mapCounter);
mapFragment.setArguments(bundle);
MapboxMapOptions mapboxMapOptions = new MapboxMapOptions();
mapboxMapOptions.styleUrl(STYLES[Math.min(Math.max(mapCounter, 0), STYLES.length - 1)]);
mapFragment.setArguments(MapFragmentUtils.createFragmentArgs(mapboxMapOptions));
return mapFragment;
}
@@ -154,6 +155,11 @@ public class BottomSheetActivity extends AppCompatActivity {
@Override
public void onMapReady(@NonNull MapboxMap mapboxMap) {
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(37.760545, -122.436055), 15));
mapboxMap.setStyle(
new Style.Builder().fromUrl(
STYLES[Math.min(Math.max(getArguments().getInt("mapcounter"), 0), STYLES.length - 1)]
)
);
}
@Override
@@ -207,7 +213,6 @@ public class BottomSheetActivity extends AppCompatActivity {
BottomSheetFragment mapFragment = new BottomSheetFragment();
MapboxMapOptions mapboxMapOptions = new MapboxMapOptions();
mapboxMapOptions.renderSurfaceOnTop(true);
mapboxMapOptions.styleUrl(Style.LIGHT);
mapFragment.setArguments(MapFragmentUtils.createFragmentArgs(mapboxMapOptions));
return mapFragment;
}
@@ -229,6 +234,7 @@ public class BottomSheetActivity extends AppCompatActivity {
@Override
public void onMapReady(@NonNull MapboxMap mapboxMap) {
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(37.760545, -122.436055), 15));
mapboxMap.setStyle(Style.LIGHT);
}
@Override

View File

@@ -98,9 +98,7 @@ public class DebugModeActivity extends AppCompatActivity implements OnMapReadyCa
}
protected MapboxMapOptions setupMapboxMapOptions() {
MapboxMapOptions mapboxMapOptions = new MapboxMapOptions();
mapboxMapOptions.styleUrl(Style.MAPBOX_STREETS);
return mapboxMapOptions;
return new MapboxMapOptions();
}
@Override

View File

@@ -9,14 +9,13 @@ import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMapOptions;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.maps.UiSettings;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.utils.MapFragmentUtils;
@@ -41,7 +40,6 @@ public class DoubleMapActivity extends AppCompatActivity {
if (savedInstanceState == null) {
MapboxMapOptions options = new MapboxMapOptions();
options.styleUrl(Style.DARK);
options.camera(new CameraPosition.Builder()
.target(MACHU_PICCHU)
.zoom(ZOOM_IN)
@@ -77,6 +75,7 @@ public class DoubleMapActivity extends AppCompatActivity {
// MapView large
mapView = new MapView(view.getContext(), MapFragmentUtils.resolveArgs(view.getContext(), getArguments()));
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(mapboxMap -> mapboxMap.setStyle(Style.MAPBOX_STREETS));
((ViewGroup) view.findViewById(R.id.container)).addView(mapView, 0);
// MapView mini
@@ -99,7 +98,7 @@ public class DoubleMapActivity extends AppCompatActivity {
mapboxMap.addOnMapClickListener(point -> {
// test if we can open 2 activities after each other
Toast.makeText(mapViewMini.getContext(), "Creating a new Activity instance",Toast.LENGTH_SHORT).show();
Toast.makeText(mapViewMini.getContext(), "Creating a new Activity instance", Toast.LENGTH_SHORT).show();
startActivity(new Intent(mapViewMini.getContext(), DoubleMapActivity.class));
return false;
@@ -150,7 +149,7 @@ public class DoubleMapActivity extends AppCompatActivity {
}
@Override
public void onSaveInstanceState(Bundle outState) {
public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
mapView.onSaveInstanceState(outState);
mapViewMini.onSaveInstanceState(outState);

View File

@@ -14,6 +14,7 @@ import com.mapbox.mapboxsdk.geometry.LatLngBounds;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.testapp.R;
/**
@@ -42,6 +43,7 @@ public class LatLngBoundsForCameraActivity extends AppCompatActivity implements
@Override
public void onMapReady(@NonNull MapboxMap mapboxMap) {
this.mapboxMap = mapboxMap;
mapboxMap.setStyle(Style.SATELLITE_STREETS);
mapboxMap.setLatLngBoundsForCameraTarget(ICELAND_BOUNDS);
mapboxMap.setMinZoomPreference(2);
showBoundsArea();

View File

@@ -6,6 +6,7 @@ import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.testapp.R;
/**
@@ -23,6 +24,7 @@ public class LocalGlyphActivity extends AppCompatActivity {
mapView = findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(mapboxMap -> {
mapboxMap.setStyle(Style.MAPBOX_STREETS);
// Set initial position to Suzhou
mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(
new CameraPosition.Builder()

View File

@@ -11,8 +11,8 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.testapp.R;
/**
@@ -28,7 +28,7 @@ public class MapInDialogActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map_in_dialog);
Button button = (Button) findViewById(R.id.button_open_dialog);
Button button = findViewById(R.id.button_open_dialog);
button.setOnClickListener(view -> {
FragmentManager fm = getSupportFragmentManager();
MapDialogFragment editNameDialogFragment = MapDialogFragment.newInstance("Map Dialog");
@@ -60,8 +60,9 @@ public class MapInDialogActivity extends AppCompatActivity {
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mapView = (MapView) view.findViewById(R.id.mapView);
mapView = view.findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(mapboxMap -> mapboxMap.setStyle(Style.OUTDOORS));
}
@NonNull
@@ -69,6 +70,7 @@ public class MapInDialogActivity extends AppCompatActivity {
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new Dialog(getActivity(), getTheme()) {
boolean destroyed = false;
@Override
public void dismiss() {
if (mapView != null && !destroyed) {

View File

@@ -11,6 +11,7 @@ import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.maps.UiSettings;
import com.mapbox.mapboxsdk.testapp.R;
@@ -33,6 +34,7 @@ public class MapPaddingActivity extends AppCompatActivity {
mapView.getMapAsync(mapboxMap -> {
MapPaddingActivity.this.mapboxMap = mapboxMap;
mapboxMap.setStyle(Style.MAPBOX_STREETS);
int paddingLeft = (int) getResources().getDimension(R.dimen.map_padding_left);
int paddingBottom = (int) getResources().getDimension(R.dimen.map_padding_bottom);

View File

@@ -9,6 +9,8 @@ import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.TextView
import com.mapbox.mapboxsdk.maps.MapView
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback
import com.mapbox.mapboxsdk.maps.Style
import com.mapbox.mapboxsdk.testapp.R
import kotlinx.android.synthetic.main.activity_recyclerview.*
@@ -65,6 +67,7 @@ class RecyclerViewActivity : AppCompatActivity() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
return if (viewType == TYPE_MAP) {
val mapView = inflater.inflate(R.layout.item_map, parent, false) as MapView
mapView.getMapAsync { mapboxMap -> mapboxMap.setStyle(Style.MAPBOX_STREETS) }
mapHolder = MapHolder(mapView, savedInstanceState)
return mapHolder as MapHolder
} else {

View File

@@ -9,6 +9,7 @@ import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.testapp.R;
/**
@@ -26,10 +27,11 @@ public class VisibilityChangeActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map_visibility);
mapView = (MapView) findViewById(R.id.mapView);
mapView = findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(map -> {
mapboxMap = map;
mapboxMap.setStyle(Style.MAPBOX_STREETS);
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
new LatLng(55.754020, 37.620948), 12), 9000);
});

View File

@@ -14,6 +14,7 @@ import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.style.layers.Layer;
import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
@@ -48,7 +49,7 @@ public class CustomSpriteActivity extends AppCompatActivity {
mapView.getMapAsync(map -> {
mapboxMap = map;
map.getStyle(style -> {
map.setStyle(Style.MAPBOX_STREETS, style -> {
final FloatingActionButton fab = findViewById(R.id.fab);
fab.setColorFilter(ContextCompat.getColor(CustomSpriteActivity.this, R.color.primary));
fab.setOnClickListener(new View.OnClickListener() {

View File

@@ -2,9 +2,9 @@ package com.mapbox.mapboxsdk.testapp.activity.style;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.testapp.R;
/**
@@ -23,7 +23,11 @@ public class FillExtrusionStyleTestActivity extends AppCompatActivity {
// Initialize map as normal
mapView = (MapView) findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(mapboxMap -> FillExtrusionStyleTestActivity.this.mapboxMap = mapboxMap);
mapView.getMapAsync(mapboxMap ->
mapboxMap.setStyle(new Style.Builder().fromUrl(Style.MAPBOX_STREETS),
style -> FillExtrusionStyleTestActivity.this.mapboxMap = mapboxMap
)
);
}
public MapboxMap getMapboxMap() {

View File

@@ -95,7 +95,7 @@ public class GridSourceActivity extends AppCompatActivity implements OnMapReadyC
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_grid_source);
mapView = (MapView) findViewById(R.id.mapView);
mapView = findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(this);
}

View File

@@ -28,7 +28,7 @@ public class HillshadeLayerActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fill_extrusion_layer);
mapView = (MapView) findViewById(R.id.mapView);
mapView = findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(map -> {
mapboxMap = map;
@@ -37,7 +37,7 @@ public class HillshadeLayerActivity extends AppCompatActivity {
HillshadeLayer hillshadeLayer = new HillshadeLayer(LAYER_ID, SOURCE_ID);
mapboxMap.setStyle(new Style.Builder()
.fromUrl(Style.MAPBOX_STREETS)
.withLayer(hillshadeLayer)
.withLayerBelow(hillshadeLayer, LAYER_BELOW_ID)
.withSource(rasterDemSource)
);
});

View File

@@ -7,12 +7,12 @@ import android.support.design.widget.FloatingActionButton;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.utils.ResourceUtils;
import timber.log.Timber;
import java.io.BufferedWriter;
import java.io.File;
@@ -20,8 +20,6 @@ import java.io.FileWriter;
import java.io.IOException;
import java.lang.ref.WeakReference;
import timber.log.Timber;
/**
* Test activity showcasing how to use a file:// resource for the style.json and how to use MapboxMap#setStyleJson.
*/
@@ -35,18 +33,19 @@ public class StyleFileActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_style_file);
mapView = (MapView) findViewById(R.id.mapView);
mapView = findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(map -> {
mapboxMap = map;
mapboxMap.setStyle(Style.MAPBOX_STREETS, style -> {
FloatingActionButton fab = findViewById(R.id.fab_file);
fab.setColorFilter(ContextCompat.getColor(StyleFileActivity.this, R.color.primary));
fab.setOnClickListener(view -> new CreateStyleFileTask(view.getContext(), mapboxMap).execute());
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab_file);
fab.setColorFilter(ContextCompat.getColor(StyleFileActivity.this, R.color.primary));
fab.setOnClickListener(view -> new CreateStyleFileTask(view.getContext(), mapboxMap).execute());
FloatingActionButton fabStyleJson = (FloatingActionButton) findViewById(R.id.fab_style_json);
fabStyleJson.setColorFilter(ContextCompat.getColor(StyleFileActivity.this, R.color.primary));
fabStyleJson.setOnClickListener(view -> new LoadStyleFileTask(view.getContext(), mapboxMap).execute());
FloatingActionButton fabStyleJson = findViewById(R.id.fab_style_json);
fabStyleJson.setColorFilter(ContextCompat.getColor(StyleFileActivity.this, R.color.primary));
fabStyleJson.setOnClickListener(view -> new LoadStyleFileTask(view.getContext(), mapboxMap).execute());
});
});
}

View File

@@ -19,6 +19,7 @@ import com.mapbox.geojson.FeatureCollection;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
@@ -89,8 +90,10 @@ public class SymbolGeneratorActivity extends AppCompatActivity implements OnMapR
@Override
public void onMapReady(@NonNull final MapboxMap map) {
mapboxMap = map;
addSymbolClickListener();
new LoadDataTask(this).execute();
map.setStyle(Style.OUTDOORS, style -> {
addSymbolClickListener();
new LoadDataTask(SymbolGeneratorActivity.this).execute();
});
}
private void addSymbolClickListener() {

View File

@@ -4,19 +4,18 @@ import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.MapboxMapOptions;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.utils.ResourceUtils;
import timber.log.Timber;
import java.io.IOException;
import timber.log.Timber;
/**
* Example showcasing how to create a TextureView with a transparent background.
*/
@@ -40,21 +39,26 @@ public class TextureViewTransparentBackgroundActivity extends AppCompatActivity
}
private void setupMapView(Bundle savedInstanceState) {
try {
MapboxMapOptions mapboxMapOptions = new MapboxMapOptions();
mapboxMapOptions.styleJson(ResourceUtils.readRawResource(this, R.raw.no_bg_style));
mapboxMapOptions.translucentTextureSurface(true);
mapboxMapOptions.textureMode(true);
mapboxMapOptions.camera(new CameraPosition.Builder()
.zoom(2)
.target(new LatLng(48.507879, 8.363795))
.build()
);
MapboxMapOptions mapboxMapOptions = new MapboxMapOptions();
mapboxMapOptions.translucentTextureSurface(true);
mapboxMapOptions.textureMode(true);
mapboxMapOptions.camera(new CameraPosition.Builder()
.zoom(2)
.target(new LatLng(48.507879, 8.363795))
.build()
);
mapView = new MapView(this, mapboxMapOptions);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(map -> mapboxMap = map);
((ViewGroup) findViewById(R.id.coordinator_layout)).addView(mapView);
mapView = new MapView(this, mapboxMapOptions);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(this::initMap);
((ViewGroup) findViewById(R.id.coordinator_layout)).addView(mapView);
}
private void initMap(MapboxMap mapboxMap) {
try {
mapboxMap.setStyle(
new Style.Builder().fromJson(ResourceUtils.readRawResource(this, R.raw.no_bg_style))
);
} catch (IOException exception) {
Timber.e(exception);
}

View File

@@ -12,8 +12,7 @@
android:layout_height="match_parent"
app:mapbox_cameraTargetLat="52.519003"
app:mapbox_cameraTargetLng="13.400972"
app:mapbox_cameraZoom="16"
app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"/>
app:mapbox_cameraZoom="16"/>
<android.support.design.widget.FloatingActionButton
android:id="@id/fab"

View File

@@ -11,7 +11,6 @@
android:layout_height="match_parent"
app:mapbox_cameraTargetLat="41.9567"
app:mapbox_cameraTargetLng="-78.6430"
app:mapbox_cameraZoom="5"
app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"/>
app:mapbox_cameraZoom="5"/>
</RelativeLayout>

View File

@@ -12,7 +12,6 @@
android:layout_height="wrap_content"
app:mapbox_cameraTargetLat="38.90962"
app:mapbox_cameraTargetLng="-77.04341"
app:mapbox_cameraZoom="15"
app:mapbox_styleUrl="@string/mapbox_style_light"/>
app:mapbox_cameraZoom="15"/>
</LinearLayout>

View File

@@ -9,8 +9,7 @@
app:mapbox_cameraTargetLat="40.7135"
app:mapbox_cameraTargetLng="-74.0066"
app:mapbox_cameraTilt="45"
app:mapbox_cameraZoom="15"
app:mapbox_styleUrl="@string/mapbox_style_dark"/>
app:mapbox_cameraZoom="15"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fabLightPosition"

View File

@@ -12,8 +12,7 @@
android:layout_height="match_parent"
app:mapbox_cameraTargetLat="37.787947"
app:mapbox_cameraTargetLng="-122.407432"
app:mapbox_cameraZoom="11"
app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"/>
app:mapbox_cameraZoom="11"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"

View File

@@ -18,8 +18,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?android:attr/actionBarSize"
app:mapbox_uiAttributionTintColor="@color/redAccent"
app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"/>
app:mapbox_uiAttributionTintColor="@color/redAccent"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"

View File

@@ -11,8 +11,7 @@
android:layout_height="match_parent"
app:mapbox_cameraTargetLat="1.350057"
app:mapbox_cameraTargetLng="103.849218"
app:mapbox_cameraZoom="10"
app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"/>
app:mapbox_cameraZoom="10"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_route"

View File

@@ -10,7 +10,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/toolbar"
app:mapbox_styleUrl="asset://streets.json"
app:mapbox_cameraZoom="1"/>
</RelativeLayout>

View File

@@ -12,7 +12,6 @@
app:mapbox_cameraTargetLat="40.7135"
app:mapbox_cameraTargetLng="-74.0066"
app:mapbox_cameraTilt="45"
app:mapbox_cameraZoom="15"
app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"/>
app:mapbox_cameraZoom="15"/>
</RelativeLayout>

View File

@@ -11,7 +11,6 @@
android:layout_height="match_parent"
app:mapbox_cameraTargetLat="41.9567"
app:mapbox_cameraTargetLng="-78.6430"
app:mapbox_cameraZoom="5"
app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"/>
app:mapbox_cameraZoom="5"/>
</RelativeLayout>

View File

@@ -11,7 +11,6 @@
android:layout_height="match_parent"
app:mapbox_cameraTargetLat="52.090710"
app:mapbox_cameraTargetLng="5.121125"
app:mapbox_cameraZoom="10"
app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"/>
app:mapbox_cameraZoom="10"/>
</RelativeLayout>

View File

@@ -12,7 +12,6 @@
android:layout_height="match_parent"
app:mapbox_cameraTargetLat="38.897705003219784"
app:mapbox_cameraTargetLng="-77.03655168667463"
app:mapbox_cameraZoom="15"
app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"/>
app:mapbox_cameraZoom="15"/>
</LinearLayout>

View File

@@ -12,7 +12,6 @@
android:layout_height="match_parent"
app:mapbox_cameraTargetLat="47.798202"
app:mapbox_cameraTargetLng="7.573781"
app:mapbox_cameraZoom="4"
app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"/>
app:mapbox_cameraZoom="4"/>
</LinearLayout>

View File

@@ -12,7 +12,6 @@
android:id="@id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"
app:mapbox_localIdeographFontFamily="Droid Sans" />
</LinearLayout>

View File

@@ -14,7 +14,6 @@
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"
app:mapbox_uiAttribution="false" />
<LinearLayout

View File

@@ -4,7 +4,6 @@
<com.mapbox.mapboxsdk.maps.MapView
android:id="@id/mapView"
android:layout_width="match_parent"
app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"
android:layout_height="match_parent"/>
<View

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/viewParent"
android:layout_width="match_parent"
android:layout_height="match_parent"
@@ -12,7 +12,6 @@
android:id="@id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"
android:visibility="invisible"/>
</LinearLayout>

View File

@@ -12,7 +12,6 @@
android:layout_below="@id/toolbar"
app:mapbox_cameraTargetLat="38.87031"
app:mapbox_cameraTargetLng="-77.00897"
app:mapbox_cameraZoom="10"
app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"/>
app:mapbox_cameraZoom="10"/>
</RelativeLayout>

View File

@@ -11,7 +11,6 @@
android:layout_height="wrap_content"
app:mapbox_cameraTargetLat="-1.063510"
app:mapbox_cameraTargetLng=" 32.895425"
app:mapbox_cameraZoom="4"
app:mapbox_styleUrl="@string/mapbox_style_satellite_streets"/>
app:mapbox_cameraZoom="4"/>
</RelativeLayout>
</RelativeLayout>

View File

@@ -23,8 +23,7 @@
android:layout_weight="0.5"
mapbox:mapbox_cameraTargetLat="38.913187"
mapbox:mapbox_cameraTargetLng="-77.032546"
mapbox:mapbox_cameraZoom="12"
mapbox:mapbox_styleUrl="mapbox://styles/mapbox/streets-v10" />
mapbox:mapbox_cameraZoom="12" />
<!-- SF -->
<fragment
@@ -35,8 +34,7 @@
android:layout_weight="0.5"
mapbox:mapbox_cameraTargetLat="37.775732"
mapbox:mapbox_cameraTargetLng="-122.413985"
mapbox:mapbox_cameraZoom="13"
mapbox:mapbox_styleUrl="mapbox://styles/mapbox/outdoors-v10" />
mapbox:mapbox_cameraZoom="13"/>
</LinearLayout>
<LinearLayout
@@ -55,8 +53,7 @@
android:layout_weight="0.5"
mapbox:mapbox_cameraTargetLat="12.97913"
mapbox:mapbox_cameraTargetLng="77.59188"
mapbox:mapbox_cameraZoom="14"
mapbox:mapbox_styleUrl="mapbox://styles/mapbox/light-v9" />
mapbox:mapbox_cameraZoom="14" />
<!-- Ayacucho -->
<fragment
@@ -67,7 +64,6 @@
android:layout_weight="0.5"
mapbox:mapbox_cameraTargetLat="-13.155980"
mapbox:mapbox_cameraTargetLng="-74.217134"
mapbox:mapbox_cameraZoom="15"
mapbox:mapbox_styleUrl="mapbox://styles/mapbox/dark-v9" />
mapbox:mapbox_cameraZoom="15" />
</LinearLayout>
</LinearLayout>

View File

@@ -12,7 +12,6 @@
app:mapbox_uiAttributionTintColor="@android:color/holo_green_dark"
app:mapbox_cameraTargetLat="47.798202"
app:mapbox_cameraTargetLng="7.573781"
app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"
app:mapbox_cameraZoom="4" />
<android.support.design.widget.FloatingActionButton

View File

@@ -13,7 +13,6 @@
app:mapbox_cameraTargetLat="45.1855569"
app:mapbox_cameraTargetLng="5.7215506"
app:mapbox_cameraZoom="11"
app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"
app:mapbox_uiAttributionGravity="top|end"
app:mapbox_uiLogoGravity="top|end"
app:mapbox_uiLogoMarginRight="28dp"/>

View File

@@ -18,7 +18,6 @@
android:layout_gravity="end|bottom"
android:layout_margin="@dimen/fab_margin"
android:src="@drawable/ic_print"
app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"
app:backgroundTint="@color/accent"/>
</android.support.design.widget.CoordinatorLayout>

View File

@@ -11,7 +11,6 @@
android:layout_height="match_parent"
app:mapbox_cameraTargetLat="52.0907"
app:mapbox_cameraTargetLng="5.1214"
app:mapbox_cameraZoom="16"
app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"/>
app:mapbox_cameraZoom="16"/>
</RelativeLayout>

View File

@@ -12,7 +12,6 @@
android:layout_height="match_parent"
app:mapbox_cameraTargetLat="64.840048"
app:mapbox_cameraTargetLng="-18.910457"
app:mapbox_cameraZoom="4"
app:mapbox_styleUrl="@string/mapbox_style_satellite_streets"/>
app:mapbox_cameraZoom="4"/>
</android.support.design.widget.CoordinatorLayout>

View File

@@ -86,7 +86,6 @@
android:layout_height="match_parent"
app:mapbox_cameraTargetLat="37.176546"
app:mapbox_cameraTargetLng="-3.599007"
app:mapbox_styleUrl="@string/mapbox_style_dark"
app:mapbox_cameraZoom="15" />
<android.support.design.widget.FloatingActionButton

View File

@@ -11,8 +11,7 @@
android:layout_height="match_parent"
app:mapbox_cameraTargetLat="52.519003"
app:mapbox_cameraTargetLng="13.400972"
app:mapbox_cameraZoom="16"
app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"/>
app:mapbox_cameraZoom="16"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_style_json"

View File

@@ -1,15 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.mapbox.mapboxsdk.maps.MapView
android:id="@id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:mapbox_styleUrl="@string/mapbox_style_outdoors"/>
android:layout_height="match_parent"/>
</RelativeLayout>

View File

@@ -11,7 +11,6 @@
android:layout_height="match_parent"
app:mapbox_cameraTargetLat="40.730648"
app:mapbox_cameraTargetLng="-73.993619"
app:mapbox_cameraZoom="11"
app:mapbox_styleUrl="@string/mapbox_style_light"/>
app:mapbox_cameraZoom="11"/>
</RelativeLayout>

View File

@@ -11,7 +11,6 @@
android:layout_height="match_parent"
mapbox:mapbox_cameraTargetLat="47.6077"
mapbox:mapbox_cameraTargetLng="-122.3421"
mapbox:mapbox_cameraZoom="11"
mapbox:mapbox_styleUrl="mapbox://styles/mapbox/streets-v10" />
mapbox:mapbox_cameraZoom="11"/>
</LinearLayout>

View File

@@ -8,5 +8,4 @@
app:mapbox_cameraTargetLat="45.38301927899065"
app:mapbox_cameraTargetLng="8.63525390625"
app:mapbox_renderTextureMode="true"
app:mapbox_cameraZoom="7"
app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"/>
app:mapbox_cameraZoom="7"/>