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

Commit

Permalink
Merge branch 'master' into ls-moving-icon-with-trailing-line
Browse files Browse the repository at this point in the history
  • Loading branch information
Langston Smith authored Apr 2, 2019
2 parents e899f52 + ed9fab1 commit c6a7aef
Show file tree
Hide file tree
Showing 28 changed files with 832 additions and 23 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

Mapbox welcomes participation and contributions from everyone.

## 7.3.0

* Multiple text field format
* Symbol listener
* Click to add image
* Symbol switch based on zoom level
* Rotating map camera
* Animated SymbolLayer icon


## 7.2.0

Expand Down
1 change: 1 addition & 0 deletions MapboxAndroidDemo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ dependencies {
implementation dependenciesList.supportCustomTabs
implementation dependenciesList.supportV4
implementation dependenciesList.supportConstraintLayout
implementation dependenciesList.supportAnimation

// Mapbox dependencies
chinaImplementation dependenciesList.mapboxChinaPlugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import com.mapbox.mapboxandroiddemo.examples.camera.AnimateMapCameraActivity;
import com.mapbox.mapboxandroiddemo.examples.camera.BoundingBoxCameraActivity;
import com.mapbox.mapboxandroiddemo.examples.camera.RestrictCameraActivity;
import com.mapbox.mapboxandroiddemo.examples.camera.SlowlyRotatingCameraActivity;
import com.mapbox.mapboxandroiddemo.examples.dds.AddRainFallStyleActivity;
import com.mapbox.mapboxandroiddemo.examples.dds.BathymetryActivity;
import com.mapbox.mapboxandroiddemo.examples.dds.ChoroplethJsonVectorMixActivity;
Expand All @@ -57,6 +58,7 @@
import com.mapbox.mapboxandroiddemo.examples.dds.SatelliteLandSelectActivity;
import com.mapbox.mapboxandroiddemo.examples.dds.StyleCirclesCategoricallyActivity;
import com.mapbox.mapboxandroiddemo.examples.dds.StyleLineIdentityPropertyActivity;
import com.mapbox.mapboxandroiddemo.examples.dds.SymbolSwitchOnZoomActivity;
import com.mapbox.mapboxandroiddemo.examples.extrusions.AdjustExtrusionLightActivity;
import com.mapbox.mapboxandroiddemo.examples.extrusions.Indoor3DMapActivity;
import com.mapbox.mapboxandroiddemo.examples.extrusions.MarathonExtrusionActivity;
Expand All @@ -83,6 +85,7 @@
import com.mapbox.mapboxandroiddemo.examples.labs.MarkerFollowingRouteActivity;
import com.mapbox.mapboxandroiddemo.examples.labs.MovingIconWithTrailingLineActivity;
import com.mapbox.mapboxandroiddemo.examples.labs.PictureInPictureActivity;
import com.mapbox.mapboxandroiddemo.examples.labs.ValueAnimatorIconAnimationActivity;
import com.mapbox.mapboxandroiddemo.examples.labs.PulsingLayerOpacityColorActivity;
import com.mapbox.mapboxandroiddemo.examples.labs.RecyclerViewOnMapActivity;
import com.mapbox.mapboxandroiddemo.examples.labs.SnakingDirectionsRouteActivity;
Expand Down Expand Up @@ -557,6 +560,14 @@ private void initializeModels() {
null,
R.string.activity_style_image_source_url, false, BuildConfig.MIN_SDK_VERSION
));
exampleItemModels.add(new ExampleItemModel(
R.id.nav_styles,
R.string.activity_styles_click_to_add_image_title,
R.string.activity_styles_click_to_add_image_description,
new Intent(MainActivity.this, ClickToAddImageActivity.class),
null,
R.string.activity_styles_click_to_add_image_url, false, BuildConfig.MIN_SDK_VERSION
));
exampleItemModels.add(new ExampleItemModel(
R.id.nav_styles,
R.string.activity_style_image_source_time_lapse_title,
Expand Down Expand Up @@ -759,6 +770,14 @@ private void initializeModels() {
null,
R.string.activity_camera_restrict_url, false, BuildConfig.MIN_SDK_VERSION));

exampleItemModels.add(new ExampleItemModel(
R.id.nav_camera,
R.string.activity_camera_slowly_rotating_title,
R.string.activity_camera_slowly_rotating_description,
new Intent(MainActivity.this, SlowlyRotatingCameraActivity.class),
null,
R.string.activity_camera_slowly_rotating_url, false, BuildConfig.MIN_SDK_VERSION));

exampleItemModels.add(new ExampleItemModel(
R.id.nav_offline,
R.string.activity_offline_simple_title,
Expand Down Expand Up @@ -1060,6 +1079,15 @@ private void initializeModels() {
null,
R.string.activity_lab_moving_icon_with_trailing_line_url, true, BuildConfig.MIN_SDK_VERSION));

exampleItemModels.add(new ExampleItemModel(
R.id.nav_lab,
R.string.activity_lab_animated_interpolator_icon_drop_title,
R.string.activity_lab_animated_interpolator_icon_drop_description,
new Intent(MainActivity.this, ValueAnimatorIconAnimationActivity.class),
null,
R.string.activity_lab_animated_interpolator_icon_drop_url, false, BuildConfig.MIN_SDK_VERSION
));

exampleItemModels.add(new ExampleItemModel(
R.id.nav_dds,
R.string.activity_dds_geojson_line_title,
Expand Down Expand Up @@ -1215,6 +1243,14 @@ private void initializeModels() {
null,
R.string.activity_dds_satellite_land_select_url, true, BuildConfig.MIN_SDK_VERSION));

exampleItemModels.add(new ExampleItemModel(
R.id.nav_dds,
R.string.activity_dds_symbol_zoom_switch_title,
R.string.activity_dds_symbol_zoom_switch_description,
new Intent(MainActivity.this, SymbolSwitchOnZoomActivity.class),
null,
R.string.activity_dds_symbol_zoom_switch_url, true, BuildConfig.MIN_SDK_VERSION));

exampleItemModels.add(new ExampleItemModel(
R.id.nav_basics,
R.string.activity_basic_simple_mapview_title,
Expand Down
9 changes: 8 additions & 1 deletion MapboxAndroidDemo/src/global/play/en-US/whatsnew
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
This update is in line with the 7.2.0 release of the Mapbox Maps SDK for Android and includes several improvements.
This update is in line with the 7.3.0 release of the Mapbox Maps SDK for Android and includes several improvements and new examples:

•Multiple text field format
•Symbol listener
•Click to add image
•Symbol switch based on zoom level
•Rotating map camera
•Animated SymbolLayer icon
23 changes: 23 additions & 0 deletions MapboxAndroidDemo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -635,13 +635,27 @@
android:name="android.support.PARENT_ACTIVITY"
android:value="com.mapbox.mapboxandroiddemo.MainActivity" />
</activity>
<activity
android:name=".examples.dds.SymbolSwitchOnZoomActivity"
android:label="@string/activity_dds_symbol_zoom_switch_title">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.mapbox.mapboxandroiddemo.MainActivity" />
</activity>
<activity
android:name=".examples.camera.RestrictCameraActivity"
android:label="@string/activity_camera_restrict_title">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.mapbox.mapboxandroiddemo.MainActivity" />
</activity>
<activity
android:name=".examples.camera.SlowlyRotatingCameraActivity"
android:label="@string/activity_camera_slowly_rotating_title">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.mapbox.mapboxandroiddemo.MainActivity" />
</activity>
<activity
android:name=".examples.plugins.BuildingPluginActivity"
android:label="@string/activity_plugins_building_plugin_title">
Expand Down Expand Up @@ -738,6 +752,15 @@
<activity
android:name=".examples.labs.MapFogBackgroundActivity"
android:label="@string/activity_lab_fog_background_title"
android:screenOrientation="portrait">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.mapbox.mapboxandroiddemo.MainActivity" />
</activity>
<activity
android:name=".examples.labs.ValueAnimatorIconAnimationActivity"
android:label="@string/activity_lab_animated_interpolator_icon_drop_title"

android:screenOrientation="portrait">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
package com.mapbox.mapboxandroiddemo.examples.camera;

import android.animation.ValueAnimator;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.view.animation.LinearInterpolator;
import android.widget.Toast;

import com.mapbox.mapboxandroiddemo.R;
import com.mapbox.mapboxsdk.Mapbox;
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.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.maps.Style;

/**
* Animate the map's camera to slowly spin around a single point ont the map.
*/
public class SlowlyRotatingCameraActivity extends AppCompatActivity implements OnMapReadyCallback,
MapboxMap.OnMapClickListener {

private static final int DESIRED_NUM_OF_SPINS = 5;
private static final int DESIRED_SECONDS_PER_ONE_FULL_360_SPIN = 40;
private MapView mapView;
private MapboxMap mapboxMap;
private ValueAnimator animator;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

// Mapbox access token is configured here. This needs to be called either in your application
// object or in the same activity which contains the mapview.
Mapbox.getInstance(this, getString(R.string.access_token));

// This contains the MapView in XML and needs to be called after the access token is configured.
setContentView(R.layout.activity_camera_slow_spin);

mapView = findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(this);
}

@Override
public void onMapReady(final MapboxMap mapboxMap) {
mapboxMap.setStyle(Style.SATELLITE_STREETS, new Style.OnStyleLoaded() {
@Override
public void onStyleLoaded(@NonNull Style style) {
SlowlyRotatingCameraActivity.this.mapboxMap = mapboxMap;

mapboxMap.addOnMapClickListener(SlowlyRotatingCameraActivity.this);

// Toast instructing user to tap on the map
Toast.makeText(
SlowlyRotatingCameraActivity.this, getString(R.string.rotating_camera_toast_instruction),
Toast.LENGTH_LONG).show();

startMapCameraSpinningAnimation(mapboxMap.getCameraPosition().target);
}
});
}

@Override
public boolean onMapClick(@NonNull LatLng point) {
startMapCameraSpinningAnimation(point);
return true;
}

/**
* Set up and start the spin animation. The Android system ValueAnimator emits a new value and that value is
* used as the map camera's new bearing rotation amount. A smooth "new helicopter" type of effect is created
* by using a LinearInterpolator.
*
* @param mapCameraTargetLocation the map location that the map camera should spin around
*/
private void startMapCameraSpinningAnimation(@NonNull final LatLng mapCameraTargetLocation) {
if (animator != null) {
animator.cancel();
}
animator = ValueAnimator.ofFloat(0, DESIRED_NUM_OF_SPINS * 360);
animator.setDuration(
// Multiplying by 1000 to convert to milliseconds
DESIRED_NUM_OF_SPINS * DESIRED_SECONDS_PER_ONE_FULL_360_SPIN * 1000);
animator.setInterpolator(new LinearInterpolator());
animator.setStartDelay(1000);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
// Retrieve the new animation number to use as the map camera bearing value
Float newBearingValue = (Float) valueAnimator.getAnimatedValue();

// Use the animation number in a new camera position and then direct the map camera to move to the new position
mapboxMap.moveCamera(CameraUpdateFactory
.newCameraPosition(new CameraPosition.Builder()
.target(new LatLng(mapCameraTargetLocation.getLatitude(), mapCameraTargetLocation.getLongitude()))
.bearing(newBearingValue)
.build()));
}
});
animator.start();
}

@Override
public void onResume() {
super.onResume();
mapView.onResume();
}

@Override
protected void onStart() {
super.onStart();
mapView.onStart();
}

@Override
protected void onStop() {
super.onStop();
mapView.onStop();
}

@Override
public void onPause() {
super.onPause();
mapView.onPause();
}

@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mapView.onSaveInstanceState(outState);
}

@Override
public void onLowMemory() {
super.onLowMemory();
mapView.onLowMemory();
}

@Override
protected void onDestroy() {
super.onDestroy();
if (mapboxMap != null) {
mapboxMap.removeOnMapClickListener(this);
}
if (animator != null) {
animator.end();
}
mapView.onDestroy();
}
}
Loading

0 comments on commit c6a7aef

Please sign in to comment.