[android] - remove MarkerView API
This commit is contained in:
@@ -1,79 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.annotations;
|
||||
|
||||
import com.mapbox.mapboxsdk.annotations.Marker;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.annotation.MarkerViewActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.model.annotations.TextMarkerViewOptions;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.TestConstants;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static android.support.test.espresso.Espresso.onView;
|
||||
import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withText;
|
||||
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class MarkerViewTest extends BaseActivityTest {
|
||||
|
||||
private Marker marker;
|
||||
|
||||
@Override
|
||||
protected Class getActivityClass() {
|
||||
return EspressoTestActivity.class;
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void addMarkerViewTest() {
|
||||
validateTestSetup();
|
||||
addAdapter();
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertEquals("Markers should be empty", 0, mapboxMap.getMarkers().size());
|
||||
|
||||
TextMarkerViewOptions options = new TextMarkerViewOptions();
|
||||
options.text(TestConstants.TEXT_MARKER_TEXT);
|
||||
options.position(new LatLng());
|
||||
options.snippet(TestConstants.TEXT_MARKER_SNIPPET);
|
||||
options.title(TestConstants.TEXT_MARKER_TITLE);
|
||||
marker = mapboxMap.addMarker(options);
|
||||
assertEquals("Markers size should be 1, ", 1, mapboxMap.getMarkers().size());
|
||||
assertEquals("Marker id should be 0", 0, marker.getId());
|
||||
assertEquals("Marker target should match", new LatLng(), marker.getPosition());
|
||||
assertEquals("Marker snippet should match", TestConstants.TEXT_MARKER_SNIPPET, marker.getSnippet());
|
||||
assertEquals("Marker target should match", TestConstants.TEXT_MARKER_TITLE, marker.getTitle());
|
||||
uiController.loopMainThreadForAtLeast(500);
|
||||
});
|
||||
onView(withText(TestConstants.TEXT_MARKER_TEXT)).check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void showInfoWindowTest() {
|
||||
validateTestSetup();
|
||||
addAdapter();
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
final TextMarkerViewOptions options = new TextMarkerViewOptions();
|
||||
options.position(new LatLng());
|
||||
options.text(TestConstants.TEXT_MARKER_TEXT);
|
||||
options.snippet(TestConstants.TEXT_MARKER_SNIPPET);
|
||||
options.title(TestConstants.TEXT_MARKER_TITLE);
|
||||
marker = mapboxMap.addMarker(options);
|
||||
uiController.loopMainThreadForAtLeast(500);
|
||||
mapboxMap.selectMarker(marker);
|
||||
});
|
||||
onView(withText(TestConstants.TEXT_MARKER_TEXT)).check(matches(isDisplayed()));
|
||||
onView(withText(TestConstants.TEXT_MARKER_TITLE)).check(matches(isDisplayed()));
|
||||
onView(withText(TestConstants.TEXT_MARKER_SNIPPET)).check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
private void addAdapter() {
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> mapboxMap.getMarkerViewManager().addMarkerViewAdapter(
|
||||
new MarkerViewActivity.TextAdapter(rule.getActivity(), mapboxMap)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -371,17 +371,6 @@
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.annotation.MarkerViewActivity"
|
||||
android:description="@string/description_view_marker"
|
||||
android:label="@string/activity_view_marker">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_annotation" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.fragment.ViewPagerActivity"
|
||||
android:description="@string/description_viewpager"
|
||||
@@ -669,17 +658,6 @@
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.annotation.MarkerViewsInRectangleActivity"
|
||||
android:description="@string/description_marker_view_rectangle"
|
||||
android:label="@string/activity_marker_view_rectangle">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_annotation" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.maplayout.LatLngBoundsForCameraActivity"
|
||||
android:description="@string/description_restricted_bounds"
|
||||
|
||||
@@ -34,7 +34,7 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconImage;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconRotate;
|
||||
|
||||
/**
|
||||
* Test activity showcasing animating MarkerViews.
|
||||
* Test activity showcasing animating a SymbolLayer.
|
||||
*/
|
||||
public class AnimatedSymbolLayerActivity extends AppCompatActivity {
|
||||
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
package com.mapbox.mapboxsdk.testapp.activity.annotation;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.app.ProgressDialog;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.content.res.ResourcesCompat;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.Menu;
|
||||
@@ -14,37 +11,30 @@ import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.mapbox.mapboxsdk.annotations.Icon;
|
||||
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
|
||||
import com.mapbox.mapboxsdk.annotations.MarkerViewOptions;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.GeoParseUtil;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.IconUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
/**
|
||||
* Test activity showcasing adding a large amount of Markers or MarkerViews.
|
||||
* Test activity showcasing adding a large amount of Markers.
|
||||
*/
|
||||
public class BulkMarkerActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
private MapView mapView;
|
||||
private boolean customMarkerView;
|
||||
private List<LatLng> locations;
|
||||
private ProgressDialog progressDialog;
|
||||
|
||||
@@ -56,11 +46,6 @@ public class BulkMarkerActivity extends AppCompatActivity implements AdapterView
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(mapboxMap -> BulkMarkerActivity.this.mapboxMap = mapboxMap);
|
||||
|
||||
final View fab = findViewById(R.id.fab);
|
||||
if (fab != null) {
|
||||
fab.setOnClickListener(new FabClickListener());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -99,38 +84,11 @@ public class BulkMarkerActivity extends AppCompatActivity implements AdapterView
|
||||
}
|
||||
|
||||
mapboxMap.clear();
|
||||
|
||||
if (locations.size() < amount) {
|
||||
amount = locations.size();
|
||||
}
|
||||
|
||||
if (customMarkerView) {
|
||||
showViewMarkers(amount);
|
||||
} else {
|
||||
showGlMarkers(amount);
|
||||
}
|
||||
}
|
||||
|
||||
private void showViewMarkers(int amount) {
|
||||
DecimalFormat formatter = new DecimalFormat("#.#####");
|
||||
Random random = new Random();
|
||||
int randomIndex;
|
||||
|
||||
int color = ResourcesCompat.getColor(getResources(), R.color.redAccent, getTheme());
|
||||
Icon icon = IconUtils.drawableToIcon(this, R.drawable.ic_droppin, color);
|
||||
|
||||
List<MarkerViewOptions> markerOptionsList = new ArrayList<>();
|
||||
for (int i = 0; i < amount; i++) {
|
||||
randomIndex = random.nextInt(locations.size());
|
||||
LatLng latLng = locations.get(randomIndex);
|
||||
MarkerViewOptions markerOptions = new MarkerViewOptions()
|
||||
.position(latLng)
|
||||
.icon(icon)
|
||||
.title(String.valueOf(i))
|
||||
.snippet(formatter.format(latLng.getLatitude()) + ", " + formatter.format(latLng.getLongitude()));
|
||||
markerOptionsList.add(markerOptions);
|
||||
}
|
||||
mapboxMap.addMarkerViews(markerOptionsList);
|
||||
showGlMarkers(amount);
|
||||
}
|
||||
|
||||
private void showGlMarkers(int amount) {
|
||||
@@ -198,67 +156,6 @@ public class BulkMarkerActivity extends AppCompatActivity implements AdapterView
|
||||
mapView.onLowMemory();
|
||||
}
|
||||
|
||||
private class FabClickListener implements View.OnClickListener {
|
||||
|
||||
private TextView viewCountView;
|
||||
|
||||
@Override
|
||||
public void onClick(final View view) {
|
||||
if (mapboxMap != null) {
|
||||
customMarkerView = true;
|
||||
|
||||
// remove fab
|
||||
view.animate().alpha(0).setListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
super.onAnimationEnd(animation);
|
||||
view.setVisibility(View.GONE);
|
||||
}
|
||||
}).start();
|
||||
|
||||
// reload markers
|
||||
Spinner spinner = (Spinner) findViewById(R.id.spinner);
|
||||
if (spinner != null) {
|
||||
int amount = Integer.valueOf(
|
||||
getResources().getStringArray(R.array.bulk_marker_list)[spinner.getSelectedItemPosition()]);
|
||||
showMarkers(amount);
|
||||
}
|
||||
|
||||
viewCountView = (TextView) findViewById(R.id.countView);
|
||||
|
||||
mapView.addOnCameraIsChangingListener(new MapView.OnCameraIsChangingListener() {
|
||||
@Override
|
||||
public void onCameraIsChanging() {
|
||||
onCameraChange();
|
||||
}
|
||||
});
|
||||
|
||||
mapView.addOnCameraDidChangeListener(new MapView.OnCameraDidChangeListener() {
|
||||
@Override
|
||||
public void onCameraDidChange(boolean animated) {
|
||||
onCameraChange();
|
||||
}
|
||||
});
|
||||
|
||||
mapboxMap.getMarkerViewManager().setOnMarkerViewClickListener(
|
||||
(marker, view1, adapter) -> {
|
||||
Toast.makeText(
|
||||
BulkMarkerActivity.this,
|
||||
"Hello " + marker.getId(),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void onCameraChange() {
|
||||
if (!mapboxMap.getMarkerViewManager().getMarkerViewAdapters().isEmpty()) {
|
||||
viewCountView.setText(String.format(Locale.getDefault(), "ViewCache size %d",
|
||||
mapboxMap.getMarkerViewManager().getMarkerViewContainer().getChildCount()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class LoadLocationTask extends AsyncTask<Void, Integer, List<LatLng>> {
|
||||
|
||||
private WeakReference<BulkMarkerActivity> activity;
|
||||
|
||||
@@ -1,490 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.activity.annotation;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorInflater;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.FloatEvaluator;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.mapbox.mapboxsdk.annotations.Icon;
|
||||
import com.mapbox.mapboxsdk.annotations.IconFactory;
|
||||
import com.mapbox.mapboxsdk.annotations.Marker;
|
||||
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
|
||||
import com.mapbox.mapboxsdk.annotations.MarkerView;
|
||||
import com.mapbox.mapboxsdk.annotations.MarkerViewManager;
|
||||
import com.mapbox.mapboxsdk.annotations.MarkerViewOptions;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.model.annotations.CountryMarkerView;
|
||||
import com.mapbox.mapboxsdk.testapp.model.annotations.CountryMarkerViewOptions;
|
||||
import com.mapbox.mapboxsdk.testapp.model.annotations.TextMarkerView;
|
||||
import com.mapbox.mapboxsdk.testapp.model.annotations.TextMarkerViewOptions;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Test activity showcasing multiple MarkerViews above Washington D.C.
|
||||
* <p>
|
||||
* Shows a couple of open InfoWindows out of current Viewport.
|
||||
* Updates the rotation and location of a couple of MarkerViews.
|
||||
* </p>
|
||||
*/
|
||||
public class MarkerViewActivity extends AppCompatActivity {
|
||||
|
||||
private static final LatLng[] LAT_LNGS = new LatLng[] {
|
||||
new LatLng(38.897424, -77.036508),
|
||||
new LatLng(38.909698, -77.029642),
|
||||
new LatLng(38.907227, -77.036530),
|
||||
new LatLng(38.905607, -77.031916),
|
||||
new LatLng(38.889441, -77.050134),
|
||||
new LatLng(38.888000, -77.050000) // Slight overlap to show re-ordering on selection
|
||||
};
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
private MapView mapView;
|
||||
private TextView viewCountView;
|
||||
|
||||
// MarkerView location updates
|
||||
private MarkerView movingMarkerOne;
|
||||
private MarkerView movingMarkerTwo;
|
||||
private Random randomAnimator = new Random();
|
||||
private Handler locationUpdateHandler = new Handler();
|
||||
private Runnable moveMarkerRunnable = new MoveMarkerRunnable();
|
||||
|
||||
// MarkerView rotate updates
|
||||
private MarkerView rotateMarker;
|
||||
private Handler rotateUpdateHandler = new Handler();
|
||||
private Runnable rotateMarkerRunnable = new RotateMarkerRunnable();
|
||||
private int rotation = 360;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_marker_view);
|
||||
|
||||
viewCountView = (TextView) findViewById(R.id.countView);
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(mapboxMap -> {
|
||||
MarkerViewActivity.this.mapboxMap = mapboxMap;
|
||||
|
||||
final MarkerViewManager markerViewManager = mapboxMap.getMarkerViewManager();
|
||||
|
||||
Icon usFlag = IconFactory.getInstance(MarkerViewActivity.this)
|
||||
.fromResource(R.drawable.ic_us);
|
||||
|
||||
// add default ViewMarker markers
|
||||
for (int i = 0; i < LAT_LNGS.length; i++) {
|
||||
MarkerViewActivity.this.mapboxMap.addMarker(new MarkerViewOptions()
|
||||
.position(LAT_LNGS[i])
|
||||
.title(String.valueOf(i))
|
||||
.alpha(0.5f)
|
||||
.icon(usFlag)
|
||||
);
|
||||
}
|
||||
|
||||
// add custom ViewMarker
|
||||
CountryMarkerViewOptions options = new CountryMarkerViewOptions();
|
||||
options.flagRes(R.drawable.icon_burned);
|
||||
options.abbrevName("Mapbox");
|
||||
options.title("Hello");
|
||||
options.position(new LatLng(38.899774, -77.023237));
|
||||
options.flat(true);
|
||||
MarkerView markerView = mapboxMap.addMarker(options);
|
||||
|
||||
// Use object animator to rotate MarkerView
|
||||
ValueAnimator markerAnimator = ObjectAnimator.ofObject(markerView, "rotation", new FloatEvaluator(), -90, 90);
|
||||
markerAnimator.setDuration(5000);
|
||||
markerAnimator.start();
|
||||
|
||||
MarkerViewActivity.this.mapboxMap.addMarker(new MarkerOptions()
|
||||
.title("United States")
|
||||
.position(new LatLng(38.902580, -77.050102))
|
||||
);
|
||||
|
||||
rotateMarker = MarkerViewActivity.this.mapboxMap.addMarker(new TextMarkerViewOptions()
|
||||
.text("A")
|
||||
.rotation(rotation = 270)
|
||||
.position(new LatLng(38.889876, -77.008849))
|
||||
);
|
||||
loopMarkerRotate();
|
||||
|
||||
|
||||
MarkerViewActivity.this.mapboxMap.addMarker(new TextMarkerViewOptions()
|
||||
.text("B")
|
||||
.position(new LatLng(38.907327, -77.041293))
|
||||
);
|
||||
|
||||
MarkerViewActivity.this.mapboxMap.addMarker(new TextMarkerViewOptions()
|
||||
.text("C")
|
||||
.position(new LatLng(38.897642, -77.041980))
|
||||
);
|
||||
|
||||
// if you want to customise a ViewMarker you need to extend ViewMarker and provide an adapter implementation
|
||||
// set adapters for child classes of ViewMarker
|
||||
markerViewManager.addMarkerViewAdapter(new CountryAdapter(MarkerViewActivity.this, mapboxMap));
|
||||
markerViewManager.addMarkerViewAdapter(new TextAdapter(MarkerViewActivity.this, mapboxMap));
|
||||
|
||||
|
||||
// add a change listener to validate the size of amount of child views
|
||||
mapView.addOnCameraDidChangeListener(new MapView.OnCameraDidChangeListener() {
|
||||
@Override
|
||||
public void onCameraDidChange(boolean animated) {
|
||||
setViewCount();
|
||||
}
|
||||
});
|
||||
|
||||
// add a OnMarkerView click listener
|
||||
MarkerViewActivity.this.mapboxMap.getMarkerViewManager().setOnMarkerViewClickListener(
|
||||
(marker, view, adapter) -> {
|
||||
Toast.makeText(MarkerViewActivity.this, "Hello " + marker.getId(), Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
});
|
||||
|
||||
movingMarkerOne = MarkerViewActivity.this.mapboxMap.addMarker(new MarkerViewOptions()
|
||||
.position(CarLocation.CAR_0_LNGS[0])
|
||||
.icon(IconFactory.getInstance(mapView.getContext())
|
||||
.fromResource(R.drawable.ic_android))
|
||||
);
|
||||
|
||||
movingMarkerTwo = mapboxMap.addMarker(new MarkerViewOptions()
|
||||
.position(CarLocation.CAR_1_LNGS[0])
|
||||
.icon(IconFactory.getInstance(mapView.getContext())
|
||||
.fromResource(R.drawable.ic_android_2))
|
||||
);
|
||||
|
||||
// allow more open infowindows at the same time
|
||||
mapboxMap.setAllowConcurrentMultipleOpenInfoWindows(true);
|
||||
|
||||
// add offscreen markers
|
||||
Marker markerRightOffScreen = mapboxMap.addMarker(new MarkerOptions()
|
||||
.setPosition(new LatLng(38.892846, -76.909399))
|
||||
.title("InfoWindow")
|
||||
.snippet("Offscreen, to the right of the Map."));
|
||||
|
||||
Marker markerRightBottomOffScreen = mapboxMap.addMarker(new MarkerOptions()
|
||||
.setPosition(new LatLng(38.791645, -77.039006))
|
||||
.title("InfoWindow")
|
||||
.snippet("Offscreen, to the bottom of the Map"));
|
||||
|
||||
// open infowindow offscreen markers
|
||||
mapboxMap.selectMarker(markerRightOffScreen);
|
||||
mapboxMap.selectMarker(markerRightBottomOffScreen);
|
||||
});
|
||||
}
|
||||
|
||||
private void setViewCount() {
|
||||
final MarkerViewManager markerViewManager = mapboxMap.getMarkerViewManager();
|
||||
final ViewGroup markerViewContainer = markerViewManager.getMarkerViewContainer();
|
||||
if (!markerViewManager.getMarkerViewAdapters().isEmpty() && viewCountView != null) {
|
||||
viewCountView.setText(String.format(
|
||||
Locale.getDefault(),
|
||||
getString(R.string.viewcache_size),
|
||||
markerViewContainer.getChildCount())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private void loopMarkerRotate() {
|
||||
rotateUpdateHandler.postDelayed(rotateMarkerRunnable, 800);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
mapView.onStart();
|
||||
loopMarkerMove();
|
||||
}
|
||||
|
||||
private void loopMarkerMove() {
|
||||
locationUpdateHandler.postDelayed(moveMarkerRunnable, randomAnimator.nextInt(3000) + 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
mapView.onStop();
|
||||
locationUpdateHandler.removeCallbacks(moveMarkerRunnable);
|
||||
rotateUpdateHandler.removeCallbacks(rotateMarkerRunnable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the position of a Marker
|
||||
*/
|
||||
private class MoveMarkerRunnable implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
int randomInteger = randomAnimator.nextInt(9);
|
||||
if (randomAnimator.nextInt() % 2 == 0) {
|
||||
movingMarkerOne.setPosition(CarLocation.CAR_0_LNGS[randomInteger]);
|
||||
} else {
|
||||
movingMarkerTwo.setPosition(CarLocation.CAR_1_LNGS[randomInteger]);
|
||||
}
|
||||
loopMarkerMove();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the rotation of a Marker
|
||||
*/
|
||||
private class RotateMarkerRunnable implements Runnable {
|
||||
|
||||
private static final int ROTATION_INCREASE_VALUE = 9;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
rotation -= ROTATION_INCREASE_VALUE;
|
||||
if (rotation >= 0) {
|
||||
rotation += 360;
|
||||
}
|
||||
rotateMarker.setRotation(rotation);
|
||||
loopMarkerRotate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapts a MarkerView to display an abbreviated name in a TextView and a flag in an ImageView.
|
||||
*/
|
||||
private static class CountryAdapter extends MapboxMap.MarkerViewAdapter<CountryMarkerView> {
|
||||
|
||||
private LayoutInflater inflater;
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
CountryAdapter(@NonNull Context context, @NonNull MapboxMap mapboxMap) {
|
||||
super(context, CountryMarkerView.class);
|
||||
this.inflater = LayoutInflater.from(context);
|
||||
this.mapboxMap = mapboxMap;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View getView(@NonNull CountryMarkerView marker, @Nullable View convertView, @NonNull ViewGroup parent) {
|
||||
ViewHolder viewHolder;
|
||||
if (convertView == null) {
|
||||
viewHolder = new ViewHolder();
|
||||
convertView = inflater.inflate(R.layout.view_custom_marker, parent, false);
|
||||
viewHolder.flag = (ImageView) convertView.findViewById(R.id.imageView);
|
||||
viewHolder.abbrev = (TextView) convertView.findViewById(R.id.textView);
|
||||
convertView.setTag(viewHolder);
|
||||
} else {
|
||||
viewHolder = (ViewHolder) convertView.getTag();
|
||||
}
|
||||
viewHolder.flag.setImageResource(marker.getFlagRes());
|
||||
viewHolder.abbrev.setText(marker.getAbbrevName());
|
||||
return convertView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSelect(
|
||||
@NonNull final CountryMarkerView marker, @NonNull final View convertView, boolean reselectionForViewReuse) {
|
||||
convertView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
||||
ObjectAnimator rotateAnimator = ObjectAnimator.ofFloat(convertView, View.ROTATION, 0, 360);
|
||||
rotateAnimator.setDuration(reselectionForViewReuse ? 0 : 350);
|
||||
rotateAnimator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
super.onAnimationEnd(animation);
|
||||
convertView.setLayerType(View.LAYER_TYPE_NONE, null);
|
||||
mapboxMap.selectMarker(marker);
|
||||
}
|
||||
});
|
||||
rotateAnimator.start();
|
||||
|
||||
// false indicates that we are calling selectMarker after our animation ourselves
|
||||
// true will let the system call it for you, which will result in showing an InfoWindow instantly
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeselect(@NonNull CountryMarkerView marker, @NonNull final View convertView) {
|
||||
convertView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
||||
ObjectAnimator rotateAnimator = ObjectAnimator.ofFloat(convertView, View.ROTATION, 360, 0);
|
||||
rotateAnimator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
super.onAnimationEnd(animation);
|
||||
convertView.setLayerType(View.LAYER_TYPE_NONE, null);
|
||||
}
|
||||
});
|
||||
rotateAnimator.start();
|
||||
}
|
||||
|
||||
private static class ViewHolder {
|
||||
ImageView flag;
|
||||
TextView abbrev;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapts a MarkerView to display text in a TextView.
|
||||
*/
|
||||
public static class TextAdapter extends MapboxMap.MarkerViewAdapter<TextMarkerView> {
|
||||
|
||||
private LayoutInflater inflater;
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
public TextAdapter(@NonNull Context context, @NonNull MapboxMap mapboxMap) {
|
||||
super(context, TextMarkerView.class);
|
||||
this.inflater = LayoutInflater.from(context);
|
||||
this.mapboxMap = mapboxMap;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View getView(@NonNull TextMarkerView marker, @Nullable View convertView, @NonNull ViewGroup parent) {
|
||||
ViewHolder viewHolder;
|
||||
if (convertView == null) {
|
||||
viewHolder = new ViewHolder();
|
||||
convertView = inflater.inflate(R.layout.view_text_marker, parent, false);
|
||||
viewHolder.textView = (TextView) convertView.findViewById(R.id.textView);
|
||||
convertView.setTag(viewHolder);
|
||||
} else {
|
||||
viewHolder = (ViewHolder) convertView.getTag();
|
||||
}
|
||||
viewHolder.textView.setText(marker.getText());
|
||||
return convertView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSelect(
|
||||
@NonNull final TextMarkerView marker, @NonNull final View convertView, boolean reselectionForViewReuse) {
|
||||
animateGrow(marker, convertView, 0);
|
||||
|
||||
// false indicates that we are calling selectMarker after our animation ourselves
|
||||
// true will let the system call it for you, which will result in showing an InfoWindow instantly
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeselect(@NonNull TextMarkerView marker, @NonNull final View convertView) {
|
||||
animateShrink(convertView, 350);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean prepareViewForReuse(@NonNull MarkerView marker, @NonNull View convertView) {
|
||||
// this method is called before a view will be reused, we need to restore view state
|
||||
// as we have scaled the view in onSelect. If not correctly applied other MarkerView will
|
||||
// become large since these have been recycled
|
||||
|
||||
// cancel ongoing animation
|
||||
convertView.animate().cancel();
|
||||
|
||||
if (marker.isSelected()) {
|
||||
// shrink view to be able to be reused
|
||||
animateShrink(convertView, 0);
|
||||
}
|
||||
|
||||
// true if you want reuse to occur automatically, false if you want to manage this yourself
|
||||
return true;
|
||||
}
|
||||
|
||||
private void animateGrow(@NonNull final MarkerView marker, @NonNull final View convertView, int duration) {
|
||||
convertView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
||||
Animator animator = AnimatorInflater.loadAnimator(convertView.getContext(), R.animator.scale_up);
|
||||
animator.setDuration(duration);
|
||||
animator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
super.onAnimationEnd(animation);
|
||||
convertView.setLayerType(View.LAYER_TYPE_NONE, null);
|
||||
mapboxMap.selectMarker(marker);
|
||||
}
|
||||
});
|
||||
animator.setTarget(convertView);
|
||||
animator.start();
|
||||
}
|
||||
|
||||
private void animateShrink(@NonNull final View convertView, int duration) {
|
||||
convertView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
||||
Animator animator = AnimatorInflater.loadAnimator(convertView.getContext(), R.animator.scale_down);
|
||||
animator.setDuration(duration);
|
||||
animator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
super.onAnimationEnd(animation);
|
||||
convertView.setLayerType(View.LAYER_TYPE_NONE, null);
|
||||
}
|
||||
});
|
||||
animator.setTarget(convertView);
|
||||
animator.start();
|
||||
}
|
||||
|
||||
private static class ViewHolder {
|
||||
TextView textView;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mapView.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
mapView.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
mapView.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mapView.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLowMemory() {
|
||||
super.onLowMemory();
|
||||
mapView.onLowMemory();
|
||||
}
|
||||
|
||||
private static class CarLocation {
|
||||
|
||||
static LatLng[] CAR_0_LNGS = new LatLng[] {
|
||||
new LatLng(38.92334425495122, -77.0533673443786),
|
||||
new LatLng(38.9234737236897, -77.05389484528261),
|
||||
new LatLng(38.9257094658146, -76.98819752280579),
|
||||
new LatLng(38.8324328369647, -77.00690648325929),
|
||||
new LatLng(38.87540698725855, -77.0093148713099),
|
||||
new LatLng(38.96499498141065, -77.07707916040054),
|
||||
new LatLng(38.90794910679896, -76.99695304153806),
|
||||
new LatLng(38.86234025281626, -76.9950528034839),
|
||||
new LatLng(38.862930274733635, -76.99647808241964)
|
||||
};
|
||||
|
||||
static LatLng[] CAR_1_LNGS = new LatLng[] {
|
||||
new LatLng(38.94237975070426, -76.98324549005675),
|
||||
new LatLng(38.941520236084486, -76.98234257804742),
|
||||
new LatLng(38.85972219720714, -76.98955808483929),
|
||||
new LatLng(38.944289166113776, -76.98584257252891),
|
||||
new LatLng(38.94375860578053, -76.98470344318412),
|
||||
new LatLng(38.943167431929645, -76.98373163938666),
|
||||
new LatLng(38.882834728904605, -77.02862535635137),
|
||||
new LatLng(38.882869724926245, -77.02992539231113),
|
||||
new LatLng(38.9371988177896, -76.97786740676564)
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.activity.annotation;
|
||||
|
||||
import android.graphics.RectF;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.mapbox.mapboxsdk.annotations.MarkerView;
|
||||
import com.mapbox.mapboxsdk.annotations.MarkerViewOptions;
|
||||
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.testapp.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
/**
|
||||
* Test activity showcasing counting MarkerViews in a rectangle.
|
||||
*/
|
||||
public class MarkerViewsInRectangleActivity extends AppCompatActivity implements OnMapReadyCallback,
|
||||
View.OnClickListener {
|
||||
|
||||
public MapView mapView;
|
||||
private MapboxMap mapboxMap;
|
||||
private View selectionBox;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_marker_view_in_rect);
|
||||
|
||||
selectionBox = findViewById(R.id.selection_box);
|
||||
|
||||
// Initialize map as normal
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapReady(@NonNull MapboxMap mapboxMap) {
|
||||
MarkerViewsInRectangleActivity.this.mapboxMap = mapboxMap;
|
||||
selectionBox.setOnClickListener(this);
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(52.0907, 5.1214), 16));
|
||||
mapboxMap.addMarker(new MarkerViewOptions().position(new LatLng(52.0907, 5.1214)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
// Query
|
||||
int top = selectionBox.getTop() - mapView.getTop();
|
||||
int left = selectionBox.getLeft() - mapView.getLeft();
|
||||
RectF box = new RectF(left, top, left + selectionBox.getWidth(), top + selectionBox.getHeight());
|
||||
Timber.i("Querying box %s", box);
|
||||
List<MarkerView> markers = mapboxMap.getMarkerViewsInRect(box);
|
||||
|
||||
// Show count
|
||||
Toast.makeText(
|
||||
MarkerViewsInRectangleActivity.this,
|
||||
String.format("%s markers inside box", markers.size()),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
mapView.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mapView.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
mapView.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
mapView.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
mapView.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mapView.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLowMemory() {
|
||||
super.onLowMemory();
|
||||
mapView.onLowMemory();
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,8 @@ import android.support.v7.app.AppCompatActivity;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mapbox.mapboxsdk.annotations.InfoWindow;
|
||||
import com.mapbox.mapboxsdk.annotations.MarkerView;
|
||||
import com.mapbox.mapboxsdk.annotations.MarkerViewOptions;
|
||||
import com.mapbox.mapboxsdk.annotations.Marker;
|
||||
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
@@ -29,7 +29,7 @@ public class DynamicInfoWindowAdapterActivity extends AppCompatActivity implemen
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
private MapView mapView;
|
||||
private MarkerView marker;
|
||||
private Marker marker;
|
||||
|
||||
private MapboxMap.OnMapClickListener mapClickListener = new MapboxMap.OnMapClickListener() {
|
||||
@Override
|
||||
@@ -87,9 +87,9 @@ public class DynamicInfoWindowAdapterActivity extends AppCompatActivity implemen
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.newLatLng(PARIS));
|
||||
}
|
||||
|
||||
private MarkerView addMarker(MapboxMap mapboxMap) {
|
||||
private Marker addMarker(MapboxMap mapboxMap) {
|
||||
return mapboxMap.addMarker(
|
||||
new MarkerViewOptions()
|
||||
new MarkerOptions()
|
||||
.position(PARIS)
|
||||
.icon(IconUtils.drawableToIcon(this, R.drawable.ic_location_city,
|
||||
ResourcesCompat.getColor(getResources(), R.color.mapbox_blue, getTheme()))
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.model.annotations;
|
||||
|
||||
import com.mapbox.mapboxsdk.annotations.BaseMarkerViewOptions;
|
||||
import com.mapbox.mapboxsdk.annotations.MarkerView;
|
||||
|
||||
public class CountryMarkerView extends MarkerView {
|
||||
|
||||
private String abbrevName;
|
||||
private int flagRes;
|
||||
|
||||
public CountryMarkerView(BaseMarkerViewOptions baseMarkerViewOptions, String abbrevName, int flagRes) {
|
||||
super(baseMarkerViewOptions);
|
||||
this.abbrevName = abbrevName;
|
||||
this.flagRes = flagRes;
|
||||
}
|
||||
|
||||
public String getAbbrevName() {
|
||||
return abbrevName;
|
||||
}
|
||||
|
||||
public int getFlagRes() {
|
||||
return flagRes;
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.model.annotations;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.mapbox.mapboxsdk.annotations.BaseMarkerViewOptions;
|
||||
import com.mapbox.mapboxsdk.annotations.Icon;
|
||||
import com.mapbox.mapboxsdk.annotations.IconFactory;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
|
||||
public class CountryMarkerViewOptions extends BaseMarkerViewOptions<CountryMarkerView, CountryMarkerViewOptions> {
|
||||
|
||||
private String abbrevName;
|
||||
private int flagRes;
|
||||
|
||||
public CountryMarkerViewOptions() {
|
||||
}
|
||||
|
||||
protected CountryMarkerViewOptions(Parcel in) {
|
||||
position((LatLng) in.readParcelable(LatLng.class.getClassLoader()));
|
||||
snippet(in.readString());
|
||||
title(in.readString());
|
||||
flat(in.readByte() != 0);
|
||||
anchor(in.readFloat(), in.readFloat());
|
||||
infoWindowAnchor(in.readFloat(), in.readFloat());
|
||||
rotation(in.readFloat());
|
||||
visible(in.readByte() != 0);
|
||||
alpha(in.readFloat());
|
||||
if (in.readByte() != 0) {
|
||||
// this means we have an icon
|
||||
String iconId = in.readString();
|
||||
Bitmap iconBitmap = in.readParcelable(Bitmap.class.getClassLoader());
|
||||
Icon icon = IconFactory.recreate(iconId, iconBitmap);
|
||||
icon(icon);
|
||||
}
|
||||
abbrevName(in.readString());
|
||||
flagRes(in.readInt());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CountryMarkerViewOptions getThis() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel out, int flags) {
|
||||
out.writeParcelable(getPosition(), flags);
|
||||
out.writeString(getSnippet());
|
||||
out.writeString(getTitle());
|
||||
out.writeByte((byte) (isFlat() ? 1 : 0));
|
||||
out.writeFloat(getAnchorU());
|
||||
out.writeFloat(getAnchorV());
|
||||
out.writeFloat(getInfoWindowAnchorU());
|
||||
out.writeFloat(getInfoWindowAnchorV());
|
||||
out.writeFloat(getRotation());
|
||||
out.writeByte((byte) (isVisible() ? 1 : 0));
|
||||
out.writeFloat(getAlpha());
|
||||
Icon icon = getIcon();
|
||||
out.writeByte((byte) (icon != null ? 1 : 0));
|
||||
if (icon != null) {
|
||||
out.writeString(getIcon().getId());
|
||||
out.writeParcelable(getIcon().getBitmap(), flags);
|
||||
}
|
||||
out.writeString(abbrevName);
|
||||
out.writeInt(flagRes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CountryMarkerView getMarker() {
|
||||
return new CountryMarkerView(this, abbrevName, flagRes);
|
||||
}
|
||||
|
||||
public CountryMarkerViewOptions abbrevName(String abbrevName) {
|
||||
this.abbrevName = abbrevName;
|
||||
return getThis();
|
||||
}
|
||||
|
||||
public CountryMarkerViewOptions flagRes(int flagRes) {
|
||||
this.flagRes = flagRes;
|
||||
return getThis();
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<CountryMarkerViewOptions> CREATOR
|
||||
= new Parcelable.Creator<CountryMarkerViewOptions>() {
|
||||
public CountryMarkerViewOptions createFromParcel(Parcel in) {
|
||||
return new CountryMarkerViewOptions(in);
|
||||
}
|
||||
|
||||
public CountryMarkerViewOptions[] newArray(int size) {
|
||||
return new CountryMarkerViewOptions[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.model.annotations;
|
||||
|
||||
import com.mapbox.mapboxsdk.annotations.BaseMarkerViewOptions;
|
||||
import com.mapbox.mapboxsdk.annotations.MarkerView;
|
||||
|
||||
public class PulseMarkerView extends MarkerView {
|
||||
|
||||
public PulseMarkerView(BaseMarkerViewOptions baseMarkerViewOptions) {
|
||||
super(baseMarkerViewOptions);
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.model.annotations;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.mapbox.mapboxsdk.annotations.BaseMarkerViewOptions;
|
||||
import com.mapbox.mapboxsdk.annotations.Icon;
|
||||
import com.mapbox.mapboxsdk.annotations.IconFactory;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
|
||||
public class PulseMarkerViewOptions extends BaseMarkerViewOptions<PulseMarkerView, PulseMarkerViewOptions> {
|
||||
|
||||
public PulseMarkerViewOptions() {
|
||||
}
|
||||
|
||||
protected PulseMarkerViewOptions(Parcel in) {
|
||||
position((LatLng) in.readParcelable(LatLng.class.getClassLoader()));
|
||||
snippet(in.readString());
|
||||
title(in.readString());
|
||||
flat(in.readByte() != 0);
|
||||
anchor(in.readFloat(), in.readFloat());
|
||||
selected = in.readByte() != 0;
|
||||
rotation(in.readFloat());
|
||||
if (in.readByte() != 0) {
|
||||
// this means we have an icon
|
||||
String iconId = in.readString();
|
||||
Bitmap iconBitmap = in.readParcelable(Bitmap.class.getClassLoader());
|
||||
Icon icon = IconFactory.recreate(iconId, iconBitmap);
|
||||
icon(icon);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PulseMarkerViewOptions getThis() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel out, int flags) {
|
||||
out.writeParcelable(getPosition(), flags);
|
||||
out.writeString(getSnippet());
|
||||
out.writeString(getTitle());
|
||||
out.writeByte((byte) (isFlat() ? 1 : 0));
|
||||
out.writeFloat(getAnchorU());
|
||||
out.writeFloat(getAnchorV());
|
||||
out.writeFloat(getInfoWindowAnchorU());
|
||||
out.writeFloat(getInfoWindowAnchorV());
|
||||
out.writeByte((byte) (selected ? 1 : 0));
|
||||
out.writeFloat(getRotation());
|
||||
Icon icon = getIcon();
|
||||
out.writeByte((byte) (icon != null ? 1 : 0));
|
||||
if (icon != null) {
|
||||
out.writeString(getIcon().getId());
|
||||
out.writeParcelable(getIcon().getBitmap(), flags);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PulseMarkerView getMarker() {
|
||||
return new PulseMarkerView(this);
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<PulseMarkerViewOptions> CREATOR
|
||||
= new Parcelable.Creator<PulseMarkerViewOptions>() {
|
||||
public PulseMarkerViewOptions createFromParcel(Parcel in) {
|
||||
return new PulseMarkerViewOptions(in);
|
||||
}
|
||||
|
||||
public PulseMarkerViewOptions[] newArray(int size) {
|
||||
return new PulseMarkerViewOptions[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.model.annotations;
|
||||
|
||||
import com.mapbox.mapboxsdk.annotations.BaseMarkerViewOptions;
|
||||
import com.mapbox.mapboxsdk.annotations.MarkerView;
|
||||
|
||||
public class TextMarkerView extends MarkerView {
|
||||
|
||||
private String text;
|
||||
|
||||
public TextMarkerView(BaseMarkerViewOptions baseMarkerViewOptions, String text) {
|
||||
super(baseMarkerViewOptions);
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.model.annotations;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.mapbox.mapboxsdk.annotations.BaseMarkerViewOptions;
|
||||
import com.mapbox.mapboxsdk.annotations.Icon;
|
||||
import com.mapbox.mapboxsdk.annotations.IconFactory;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
|
||||
public class TextMarkerViewOptions extends BaseMarkerViewOptions<TextMarkerView, TextMarkerViewOptions> {
|
||||
|
||||
private String text;
|
||||
|
||||
public TextMarkerViewOptions() {
|
||||
}
|
||||
|
||||
protected TextMarkerViewOptions(Parcel in) {
|
||||
position((LatLng) in.readParcelable(LatLng.class.getClassLoader()));
|
||||
snippet(in.readString());
|
||||
title(in.readString());
|
||||
flat(in.readByte() != 0);
|
||||
anchor(in.readFloat(), in.readFloat());
|
||||
infoWindowAnchor(in.readFloat(), in.readFloat());
|
||||
rotation(in.readFloat());
|
||||
visible(in.readByte() != 0);
|
||||
alpha(in.readFloat());
|
||||
if (in.readByte() != 0) {
|
||||
// this means we have an icon
|
||||
String iconId = in.readString();
|
||||
Bitmap iconBitmap = in.readParcelable(Bitmap.class.getClassLoader());
|
||||
Icon icon = IconFactory.recreate(iconId, iconBitmap);
|
||||
icon(icon);
|
||||
}
|
||||
text(in.readString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextMarkerViewOptions getThis() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel out, int flags) {
|
||||
out.writeParcelable(getPosition(), flags);
|
||||
out.writeString(getSnippet());
|
||||
out.writeString(getTitle());
|
||||
out.writeByte((byte) (isFlat() ? 1 : 0));
|
||||
out.writeFloat(getAnchorU());
|
||||
out.writeFloat(getAnchorV());
|
||||
out.writeFloat(getInfoWindowAnchorU());
|
||||
out.writeFloat(getInfoWindowAnchorV());
|
||||
out.writeFloat(getRotation());
|
||||
out.writeByte((byte) (isVisible() ? 1 : 0));
|
||||
out.writeFloat(alpha);
|
||||
Icon icon = getIcon();
|
||||
out.writeByte((byte) (icon != null ? 1 : 0));
|
||||
if (icon != null) {
|
||||
out.writeString(getIcon().getId());
|
||||
out.writeParcelable(getIcon().getBitmap(), flags);
|
||||
}
|
||||
out.writeString(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextMarkerView getMarker() {
|
||||
return new TextMarkerView(this, text);
|
||||
}
|
||||
|
||||
public TextMarkerViewOptions text(String text) {
|
||||
this.text = text;
|
||||
return getThis();
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<CountryMarkerViewOptions> CREATOR
|
||||
= new Parcelable.Creator<CountryMarkerViewOptions>() {
|
||||
public CountryMarkerViewOptions createFromParcel(Parcel in) {
|
||||
return new CountryMarkerViewOptions(in);
|
||||
}
|
||||
|
||||
public CountryMarkerViewOptions[] newArray(int size) {
|
||||
return new CountryMarkerViewOptions[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -15,24 +15,4 @@
|
||||
app:mapbox_cameraZoom="10"
|
||||
app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/countView"
|
||||
android:textIsSelectable="false"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/toolbar"
|
||||
android:padding="16dp"
|
||||
android:textSize="20sp"/>
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_gravity="end|bottom"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
android:src="@drawable/ic_animate_coordinates"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
<?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">
|
||||
|
||||
<com.mapbox.mapboxsdk.maps.MapView
|
||||
android:id="@id/mapView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@id/toolbar"
|
||||
android:textIsSelectable="false"
|
||||
app:mapbox_cameraTargetLat="38.907192"
|
||||
app:mapbox_cameraTargetLng="-77.036871"
|
||||
app:mapbox_cameraZoom="12"
|
||||
app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/countView"
|
||||
android:textIsSelectable="false"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="16dp"
|
||||
android:textSize="20sp"/>
|
||||
|
||||
</RelativeLayout>
|
||||
@@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.mapbox.mapboxsdk.maps.MapView
|
||||
android:id="@+id/mapView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/selection_box"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="150dp"
|
||||
android:layout_centerInParent="true"
|
||||
android:alpha="0.3"
|
||||
android:background="@color/mapboxGreen"/>
|
||||
|
||||
</RelativeLayout>
|
||||
@@ -25,7 +25,6 @@
|
||||
<string name="description_scroll_by">Scroll with pixels in x,y direction</string>
|
||||
<string name="description_snapshot">Example to make a snapshot of the map</string>
|
||||
<string name="description_doublemap">2 maps in a view hierarchy</string>
|
||||
<string name="description_view_marker">Use an Android SDK View as marker</string>
|
||||
<string name="description_dynamic_info_window_adapter">Learn how to create a dynamic custom InfoWindow</string>
|
||||
<string name="description_viewpager">Use SupportMapFragments in a ViewPager</string>
|
||||
<string name="description_runtime_style">Adopt the map style on the fly</string>
|
||||
@@ -47,7 +46,6 @@
|
||||
<string name="description_add_remove_markers">Change Symbol icon when zoom levels changes</string>
|
||||
<string name="description_style_file">Use a local file as the style</string>
|
||||
<string name="description_map_in_dialog">Display a map inside a dialog fragment</string>
|
||||
<string name="description_marker_view_rectangle">Marker Views within a rectangle</string>
|
||||
<string name="description_circle_layer">Show bus stops and route in Singapore</string>
|
||||
<string name="description_url_transform">Transform urls on the fly</string>
|
||||
<string name="description_restricted_bounds">Limit viewport to Iceland</string>
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
<string name="activity_polyline">Polyline</string>
|
||||
<string name="activity_polygon">Polygon</string>
|
||||
<string name="activity_press_for_marker">Press Map For Marker</string>
|
||||
<string name="activity_view_marker">View Marker API</string>
|
||||
<string name="activity_add_remove_markers">Zoom function with SymbolLayer</string>
|
||||
<string name="activity_info_window">Standard InfoWindow</string>
|
||||
<string name="activity_infowindow_adapter">Custom InfoWindow</string>
|
||||
@@ -48,7 +47,6 @@
|
||||
<string name="activity_map_change">Map Change Events</string>
|
||||
<string name="activity_map_visibility">Visibility Map</string>
|
||||
<string name="activity_map_in_dialog">Dialog with map</string>
|
||||
<string name="activity_marker_view_rectangle">Marker views in rectangle</string>
|
||||
<string name="activity_url_transform">Url transform</string>
|
||||
<string name="activity_restricted_bounds">Restrict camera to a bounds</string>
|
||||
<string name="activity_fill_extrusion_layer">Fill extrusions</string>
|
||||
|
||||
Reference in New Issue
Block a user