Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Commit

Permalink
review tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
langsmith committed Jul 2, 2019
1 parent b16f070 commit 0f8d2e6
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,27 @@
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import com.mapbox.mapboxandroiddemo.R;

import com.mapbox.mapboxandroiddemo.R;
import com.mapbox.mapboxsdk.Mapbox;
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.layers.CircleLayer;
import com.mapbox.mapboxsdk.style.sources.VectorSource;

import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleColor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleOpacity;
import static com.mapbox.mapboxsdk.style.expressions.Expression.exponential;
import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
import static com.mapbox.mapboxsdk.style.expressions.Expression.interpolate;
import static com.mapbox.mapboxsdk.style.expressions.Expression.stop;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleColor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleOpacity;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleRadius;

/**
* Set the radii of a CircleLayer's circles based on a data property.
*/
public class CircleRadiusActivity extends AppCompatActivity {

private MapView mapView;
Expand All @@ -37,13 +39,13 @@ protected void onCreate(Bundle savedInstanceState) {
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(@NonNull final MapboxMap mapboxMap) {

mapboxMap.setStyle(Style.DARK, new Style.OnStyleLoaded() {
@Override
public void onStyleLoaded(@NonNull Style style) {
// replace examples.8mj5l1r9 with the map ID for the tileset
// you created by uploading data to your Mapbox account
style.addSource(new VectorSource("trees-source", "mapbox://examples.8mj5l1r9"));

CircleLayer circleLayer = new CircleLayer("trees-style", "trees-source");
// replace street-trees-DC-9gvg5l with the name of your source layer
circleLayer.setSourceLayer("street-trees-DC-9gvg5l");
Expand All @@ -65,7 +67,6 @@ public void onStyleLoaded(@NonNull Style style) {
});
}


// Add the mapView's own lifecycle methods to the activity's lifecycle methods
@Override
public void onStart() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,52 +1,49 @@
package com.mapbox.mapboxandroiddemo.examples.location;

import com.mapbox.mapboxandroiddemo.R;
import android.annotation.SuppressLint;
import android.location.Location;
import android.util.Log;
import android.widget.Toast;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.annotation.NonNull;
// Classes needed to initialize the map
import com.mapbox.mapboxsdk.Mapbox;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.maps.Style;
// Classes needed to handle location permissions
import com.mapbox.android.core.permissions.PermissionsListener;
import com.mapbox.android.core.permissions.PermissionsManager;
import java.util.List;
// Classes needed to add the location engine
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.Toast;

import com.mapbox.android.core.location.LocationEngine;
import com.mapbox.android.core.location.LocationEngineCallback;
import com.mapbox.android.core.location.LocationEngineProvider;
import com.mapbox.android.core.location.LocationEngineRequest;
import com.mapbox.android.core.location.LocationEngineResult;
import java.lang.ref.WeakReference;
// Classes needed to add the location component
import com.mapbox.android.core.permissions.PermissionsListener;
import com.mapbox.android.core.permissions.PermissionsManager;
import com.mapbox.mapboxandroiddemo.R;
import com.mapbox.mapboxsdk.Mapbox;
import com.mapbox.mapboxsdk.location.LocationComponent;
import com.mapbox.mapboxsdk.location.LocationComponentActivationOptions;
import com.mapbox.mapboxsdk.location.modes.CameraMode;
import com.mapbox.mapboxsdk.location.modes.RenderMode;
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 java.lang.ref.WeakReference;
import java.util.List;


/**
* Use the Mapbox Core Library to listen to device location updates
* Use the Mapbox Core Library to receive updates when the device changes location.
*/
public class LocationChangeListeningActivity extends AppCompatActivity implements
OnMapReadyCallback, PermissionsListener {
// Variables needed to initialize a map

private static final long DEFAULT_INTERVAL_IN_MILLISECONDS = 1000L;
private static final long DEFAULT_MAX_WAIT_TIME = DEFAULT_INTERVAL_IN_MILLISECONDS * 5;
private MapboxMap mapboxMap;
private MapView mapView;
// Variables needed to handle location permissions
private PermissionsManager permissionsManager;
// Variables needed to add the location engine
private LocationEngine locationEngine;
private long DEFAULT_INTERVAL_IN_MILLISECONDS = 1000L;
private long DEFAULT_MAX_WAIT_TIME = DEFAULT_INTERVAL_IN_MILLISECONDS * 5;
// Variables needed to listen to location updates
private LocationChangeListeningActivityLocationCallback callback = new LocationChangeListeningActivityLocationCallback(this);
private LocationChangeListeningActivityLocationCallback callback =
new LocationChangeListeningActivityLocationCallback(this);

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -69,12 +66,11 @@ public void onMapReady(@NonNull final MapboxMap mapboxMap) {
this.mapboxMap = mapboxMap;

mapboxMap.setStyle(Style.TRAFFIC_NIGHT,
new Style.OnStyleLoaded() {
@Override
public void onStyleLoaded(@NonNull Style style) {
enableLocationComponent(style);
}
});
new Style.OnStyleLoaded() {
@Override public void onStyleLoaded(@NonNull Style style) {
enableLocationComponent(style);
}
});
}

/**
Expand Down Expand Up @@ -129,13 +125,15 @@ private void initLocationEngine() {
}

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
@NonNull int[] grantResults) {
permissionsManager.onRequestPermissionsResult(requestCode, permissions, grantResults);
}

@Override
public void onExplanationNeeded(List<String> permissionsToExplain) {
Toast.makeText(this, R.string.user_location_permission_explanation, Toast.LENGTH_LONG).show();
Toast.makeText(this, R.string.user_location_permission_explanation,
Toast.LENGTH_LONG).show();
}

@Override
Expand Down Expand Up @@ -177,7 +175,8 @@ public void onSuccess(LocationEngineResult result) {

// Create a Toast which displays the new location's coordinates
Toast.makeText(activity, String.format(activity.getString(R.string.new_location),
String.valueOf(result.getLastLocation().getLatitude()), String.valueOf(result.getLastLocation().getLongitude())),
String.valueOf(result.getLastLocation().getLatitude()),
String.valueOf(result.getLastLocation().getLongitude())),
Toast.LENGTH_SHORT).show();

// Pass the new location to the Maps SDK's LocationComponent
Expand All @@ -188,7 +187,7 @@ public void onSuccess(LocationEngineResult result) {
}

/**
* The LocationEngineCallback interface's method which fires when the device's location can not be captured
* The LocationEngineCallback interface's method which fires when the device's location can't be captured
*
* @param exception the exception message
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
package com.mapbox.mapboxandroiddemo.examples.styles;

import com.mapbox.mapboxandroiddemo.R;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.mapbox.mapboxandroiddemo.R;
import com.mapbox.mapboxsdk.Mapbox;
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.layers.Layer;

import com.mapbox.mapboxsdk.style.layers.PropertyFactory;

import android.graphics.Color;
import android.view.View;

/**
* Change various properties of a map based on user interaction and other runtime situations.
*/
public class RuntimeStylingActivity extends AppCompatActivity {

private MapView mapView;
private FloatingActionButton changeMapPropertiesFab;
private Layer waterLayer;

@Override
Expand All @@ -31,17 +30,16 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_styles_runtime_styling);
mapView = findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
changeMapPropertiesFab = findViewById(R.id.floatingActionButton);
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(@NonNull final MapboxMap mapboxMap) {
mapboxMap.setStyle(Style.MAPBOX_STREETS, new Style.OnStyleLoaded() {
@Override
public void onStyleLoaded(@NonNull final Style style) {
waterLayer = style.getLayer("water");
changeMapPropertiesFab.setOnClickListener(new View.OnClickListener() {
findViewById(R.id.floatingActionButton).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
public void onClick(View view) {
if (waterLayer != null) {
waterLayer.setProperties(PropertyFactory.fillColor(Color.parseColor("#023689"))
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.mapbox.mapboxandroiddemo.examples.styles.RuntimeStylingActivity">

<com.mapbox.mapboxsdk.maps.MapView
android:id="@+id/runtime_mapview"
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
mapbox:mapbox_cameraTargetLat="19.948045"
Expand All @@ -19,6 +20,7 @@
android:id="@+id/floatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/ic_swap_horiz_white_24dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<string name="activity_dds_expression_integration_description">Use multiple expressions to convert and visualize data.</string>
<string name="activity_dds_satellite_land_select_description">View satellite photos and click to outline an area of land.</string>
<string name="activity_dds_symbol_zoom_switch_description">Change SymbolLayer icons based on the camera\'s zoom level.</string>
<string name="activity_dds_circle_radius_description">Set the circle radius of features in a circle layer based on a data property.</string>
<string name="activity_dds_circle_radius_description">Set the radii of a circle layer\'s circles based on a data property.</string>
<string name="activity_annotation_marker_description">Create a default marker with an InfoWindow.</string>
<string name="activity_dds_geojson_line_description">Draw a polyline by parsing a GeoJSON file with the Mapbox Maps SDK.</string>
<string name="activity_dds_polygon_select_toggle_description">Tap on various polygons to "select" them and toggle their colors.</string>
Expand Down Expand Up @@ -103,7 +103,7 @@
<string name="activity_location_user_location_map_frag_plugin_description">Use the LocationComponent to display a user\'s location on a map fragment.</string>
<string name="activity_location_location_component_options_description">Use LocationComponent options to customize the user location information.</string>
<string name="activity_location_location_component_camera_options_description">Use LocationComponent camera options to customize map camera behavior.</string>
<string name="activity_location_location_change_listening_description">Display a Mapbox map on an Android device and receive updates on the current device location.</string>
<string name="activity_location_location_change_listening_description">Receive updates when the device changes location.</string>
<string name="activity_java_services_simplify_polyline_description">Using the polylines utility, simplify a polyline which reduces the amount of coordinates making up the polyline depending on tolerance.</string>
<string name="activity_java_services_map_matching_description">Match raw GPS points to the map so they aligns with the roads/pathways.</string>
<string name="activity_image_generator_snapshot_share_description">Send and share a map snapshot image.</string>
Expand Down
2 changes: 1 addition & 1 deletion MapboxAndroidDemo/src/main/res/values/titles_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<string name="activity_styles_rotating_anchor_text_title">Text anchor position</string>
<string name="activity_styles_missing_icon_title">Style with missing icon</string>
<string name="activity_styles_variable_label_placement_title">Variable label placement</string>
<string name="activity_styles_runtime_styling_title">Style features at runtime</string>
<string name="activity_styles_runtime_styling_title">Button interaction styling</string>
<string name="activity_extrusions_catalina_marathon_extrusions_title">Use GeoJSON data to set extrusion height</string>
<string name="activity_extrusions_population_density_extrusions_title">Display 3D building height based on vector data</string>
<string name="activity_extrusions_adjust_extrusions_title">Adjust light location and color</string>
Expand Down

0 comments on commit 0f8d2e6

Please sign in to comment.