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

Commit

Permalink
camera changes
Browse files Browse the repository at this point in the history
  • Loading branch information
langsmith committed May 23, 2019
1 parent ce6c00d commit c4100ef
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion MapboxAndroidDemo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
</activity>
<activity
android:name=".examples.dds.RevealedPolygonHoleOutlineActivity"
android:label="@string/activity_dds_geojson_line_title">
android:label="@string/activity_dds_polygon_revealed_hole_outline_title">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.mapbox.mapboxandroiddemo.MainActivity" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import com.mapbox.geojson.Polygon;
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.geometry.LatLngBounds;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
Expand Down Expand Up @@ -52,6 +52,7 @@ public class RevealedPolygonHoleOutlineActivity extends AppCompatActivity implem
private static final int RED_COLOR = Color.parseColor("#BF544C");
private MapView mapView;
private MapboxMap mapboxMap;
private Style style;
private static final List<Point> OUTER_POLYGON_COORDINATES = new ArrayList<Point>() {
{
add(Point.fromLngLat(-121.9921875, 37.27787748952485));
Expand All @@ -61,6 +62,10 @@ public class RevealedPolygonHoleOutlineActivity extends AppCompatActivity implem
add(Point.fromLngLat(-121.9921875, 37.27787748952485));
}
};
private static final LatLngBounds RESTRICTED_BOUNDS_AREA = new LatLngBounds.Builder()
.include(new LatLng(37.27787748952485,-121.9921875))
.include(new LatLng(37.40452830389465,-121.79580688476562))
.build();

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -81,6 +86,9 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
public void onMapReady(final MapboxMap map) {
this.mapboxMap = map;
// Set the boundary area for the map camera
mapboxMap.setLatLngBoundsForCameraTarget(RESTRICTED_BOUNDS_AREA);

map.setStyle(Style.MAPBOX_STREETS, new Style.OnStyleLoaded() {
@Override
public void onStyleLoaded(@NonNull Style style) {
Expand All @@ -94,13 +102,11 @@ private void addStyling(@NonNull List<Point> pointList) {
Style loadedStyle = mapboxMap.getStyle();

List<LineString> innerList = new ArrayList<>();

LineString innerLineString = LineString.fromLngLats(pointList);

innerList.add(innerLineString);

List<List<Point>> megaInnerList = new ArrayList<>();
megaInnerList.add(pointList);

loadedStyle.addSource(new GeoJsonSource(FILL_SOURCE_ID,
Polygon.fromOuterInner(LineString.fromLngLats(OUTER_POLYGON_COORDINATES), innerList)));

Expand All @@ -116,11 +122,6 @@ private void addStyling(@NonNull List<Point> pointList) {
lineCap(Property.LINE_CAP_ROUND),
lineJoin(Property.LINE_JOIN_ROUND)
));

mapboxMap.animateCamera(
CameraUpdateFactory.newCameraPosition(new CameraPosition.Builder()
.zoom(11)
.build()), 3000);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
mapbox:mapbox_cameraTargetLat="37.34109311809737"
mapbox:mapbox_cameraTargetLng="-121.89262390136717"
mapbox:mapbox_cameraZoom="7"/>
mapbox:mapbox_cameraTargetLat="37.331383"
mapbox:mapbox_cameraTargetLng="-121.888902"
mapbox:mapbox_cameraZoom="12"
mapbox:mapbox_cameraZoomMin="11.6" />

</FrameLayout>

0 comments on commit c4100ef

Please sign in to comment.