[android] #3758 - Projection / Visible Region implementation.
[android] #3758 - add VisibleRegion + unit tests, removed boundingbox, cleanup jni, cleanup test app, renamed CoordinateSpan to LatLng.
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
android:name=".MapboxMapActivity"
|
||||
android:label="@string/action_mapboxmap" />
|
||||
<activity
|
||||
android:name=".VisibleCoordinateBoundsActivity"
|
||||
android:name=".LatLngBoundsActivity"
|
||||
android:label="@string/activity_visible_coordinate_bounds" />
|
||||
<activity
|
||||
android:name=".InfoWindowAdapterActivity"
|
||||
|
||||
@@ -5,9 +5,11 @@ import android.support.annotation.NonNull;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
|
||||
import com.mapbox.mapboxsdk.constants.MapboxConstants;
|
||||
import com.mapbox.mapboxsdk.maps.CameraUpdateFactory;
|
||||
import com.mapbox.mapboxsdk.constants.Style;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
@@ -18,12 +20,13 @@ import com.mapbox.mapboxsdk.maps.UiSettings;
|
||||
import com.mapbox.mapboxsdk.utils.ApiAccess;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
|
||||
public class VisibleCoordinateBoundsActivity extends AppCompatActivity {
|
||||
public class LatLngBoundsActivity extends AppCompatActivity {
|
||||
|
||||
private MapView mMapView;
|
||||
private static final LatLng LOS_ANGELES = new LatLng(34.053940, -118.242622);
|
||||
private static final LatLng NEW_YORK = new LatLng(40.712730, -74.005953);
|
||||
|
||||
private MapView mMapView;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -68,8 +71,11 @@ public class VisibleCoordinateBoundsActivity extends AppCompatActivity {
|
||||
// And padding
|
||||
int padding = (int) getResources().getDimension(R.dimen.coordinatebounds_margin);
|
||||
|
||||
// Animate camera
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, padding));
|
||||
// Move camera to the bounds with padding
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, padding));
|
||||
|
||||
// Call mapboxMap.getProjection().getVisibleRegion().latLngBounds to retrieve the bounds
|
||||
Log.v(MapboxConstants.TAG, mapboxMap.getProjection().getVisibleRegion().latLngBounds.toString());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -38,7 +38,6 @@ import com.mapbox.mapboxsdk.constants.Style;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.layers.CustomLayer;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.maps.SupportMapFragment;
|
||||
import com.mapbox.mapboxsdk.maps.UiSettings;
|
||||
import com.mapbox.mapboxsdk.testapp.layers.ExampleCustomLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.GeoParseUtil;
|
||||
@@ -403,7 +402,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
return true;
|
||||
|
||||
case R.id.action_visible_bounds:
|
||||
startActivity(new Intent(getApplicationContext(), VisibleCoordinateBoundsActivity.class));
|
||||
startActivity(new Intent(getApplicationContext(), LatLngBoundsActivity.class));
|
||||
return true;
|
||||
|
||||
case R.id.action_user_tracking_mode:
|
||||
|
||||
@@ -83,7 +83,7 @@ public class PressForMarkerActivity extends AppCompatActivity implements MapboxM
|
||||
|
||||
@Override
|
||||
public void onMapLongClick(@NonNull LatLng point) {
|
||||
PointF pixel = mMapboxMap.toScreenLocation(point);
|
||||
PointF pixel = mMapboxMap.getProjection().toScreenLocation(point);
|
||||
String title = LAT_LON_FORMATTER.format(point.getLatitude()) + ", " + LAT_LON_FORMATTER.format(point.getLongitude());
|
||||
String snippet = "X = " + (int) pixel.x + ", Y = " + (int) pixel.y;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user