Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[android] #4018 - exposed max/min zoom as a configurable attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
tobrun committed Feb 18, 2016
1 parent 374f464 commit abe0fbd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,15 @@ private void initialize(@NonNull Context context, @Nullable AttributeSet attrs)
mMapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));

// Access token
if (typedArray.getString(R.styleable.MapView_access_token) != null) {
String accessToken = typedArray.getString(R.styleable.MapView_access_token);
if (accessToken != null) {
setAccessToken(typedArray.getString(R.styleable.MapView_access_token));
}

// Style url
if (typedArray.getString(R.styleable.MapView_style_url) != null) {
mMapboxMap.setStyleUrl(typedArray.getString(R.styleable.MapView_style_url));
String styleUrl = typedArray.getString(R.styleable.MapView_style_url);
if (styleUrl != null) {
mMapboxMap.setStyleUrl(styleUrl);
}

// Enable gestures
Expand All @@ -255,6 +257,10 @@ private void initialize(@NonNull Context context, @Nullable AttributeSet attrs)
uiSettings.setTiltGesturesEnabled(typedArray.getBoolean(R.styleable.MapView_tilt_enabled, true));
uiSettings.setZoomControlsEnabled(typedArray.getBoolean(R.styleable.MapView_zoom_controls_enabled, false));

// Zoom
uiSettings.setMaxZoom(typedArray.getFloat(R.styleable.MapView_zoom_max, (float) MapboxConstants.MAXIMUM_ZOOM));
uiSettings.setMinZoom(typedArray.getFloat(R.styleable.MapView_zoom_min, (float) MapboxConstants.MINIMUM_ZOOM));

// Compass
uiSettings.setCompassEnabled(typedArray.getBoolean(R.styleable.MapView_compass_enabled, true));
uiSettings.setCompassGravity(typedArray.getInt(R.styleable.MapView_compass_gravity, Gravity.TOP | Gravity.END));
Expand All @@ -280,13 +286,7 @@ private void initialize(@NonNull Context context, @Nullable AttributeSet attrs)
, (int) (typedArray.getDimension(R.styleable.MapView_attribution_margin_bottom, DIMENSION_SEVEN_DP) * mScreenDensity));

// User location
try {
//noinspection ResourceType
mMapboxMap.setMyLocationEnabled(typedArray.getBoolean(R.styleable.MapView_my_location_enabled, false));
} catch (SecurityException ignore) {
// User did not accept location permissions
}

mMapboxMap.setMyLocationEnabled(typedArray.getBoolean(R.styleable.MapView_my_location_enabled, false));
} finally {
typedArray.recycle();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<attr name="center_longitude" format="float" />
<attr name="center_latitude" format="float" />
<attr name="zoom" format="float" />
<attr name="zoom_max" format="float" />
<attr name="zoom_min" format="float" />
<attr name="direction" format="float" />
<attr name="tilt" format="float" />
<attr name="zoom_enabled" format="boolean" />
Expand Down

0 comments on commit abe0fbd

Please sign in to comment.