This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[android] - add example of camera zoom function on a symbol layer.
- Loading branch information
Showing
8 changed files
with
144 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
188 changes: 0 additions & 188 deletions
188
...c/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AddRemoveMarkerActivity.java
This file was deleted.
Oops, something went wrong.
123 changes: 123 additions & 0 deletions
123
...ain/java/com/mapbox/mapboxsdk/testapp/activity/style/ZoomFunctionSymbolLayerActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
package com.mapbox.mapboxsdk.testapp.activity.style; | ||
|
||
import android.os.Bundle; | ||
import android.support.annotation.NonNull; | ||
import android.support.v7.app.AppCompatActivity; | ||
|
||
import com.mapbox.mapboxsdk.maps.MapView; | ||
import com.mapbox.mapboxsdk.maps.MapboxMap; | ||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; | ||
import com.mapbox.mapboxsdk.style.layers.SymbolLayer; | ||
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource; | ||
import com.mapbox.mapboxsdk.testapp.R; | ||
|
||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
|
||
import timber.log.Timber; | ||
|
||
import static com.mapbox.mapboxsdk.style.functions.Function.zoom; | ||
import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop; | ||
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.interval; | ||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconAllowOverlap; | ||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconImage; | ||
|
||
public class ZoomFunctionSymbolLayerActivity extends AppCompatActivity { | ||
|
||
private static final String SOURCE_URL = "https://gist.githubusercontent.com/anonymous/" | ||
+ "70ddad0e58520307cd1699e704f4b626/raw/a5deaccdc4517c12d63b1f8abcb7becf5e36506a/map.geojson"; | ||
private static final String LAYER_ID = "symbolLayer"; | ||
private static final String SOURCE_ID = "poiSource"; | ||
private static final String BUS_MAKI_ICON_ID = "bus-11"; | ||
private static final String CAFE_MAKI_ICON_ID = "cafe-11"; | ||
private static final float ZOOM_STOP_MIN_VALUE = 7.0f; | ||
private static final float ZOOM_STOP_MAX_VALUE = 12.0f; | ||
|
||
private MapView mapView; | ||
private MapboxMap mapboxMap; | ||
private GeoJsonSource source; | ||
|
||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_zoom_symbol_layer); | ||
|
||
mapView = (MapView) findViewById(R.id.mapView); | ||
mapView.onCreate(savedInstanceState); | ||
mapView.getMapAsync(new OnMapReadyCallback() { | ||
@Override | ||
public void onMapReady(@NonNull final MapboxMap map) { | ||
mapboxMap = map; | ||
addSource(); | ||
addLayer(); | ||
} | ||
}); | ||
} | ||
|
||
private void addSource() { | ||
try { | ||
source = new GeoJsonSource(SOURCE_ID, new URL(SOURCE_URL)); | ||
} catch (MalformedURLException exception) { | ||
Timber.e(exception, "That's not an url... "); | ||
} | ||
mapboxMap.addSource(source); | ||
} | ||
|
||
private void addLayer() { | ||
SymbolLayer layer = new SymbolLayer(LAYER_ID, SOURCE_ID); | ||
layer.setProperties( | ||
iconImage( | ||
zoom( | ||
interval( | ||
stop(ZOOM_STOP_MIN_VALUE, iconImage(BUS_MAKI_ICON_ID)), | ||
stop(ZOOM_STOP_MAX_VALUE, iconImage(CAFE_MAKI_ICON_ID)) | ||
) | ||
) | ||
), | ||
iconAllowOverlap(true) | ||
); | ||
mapboxMap.addLayer(layer); | ||
} | ||
|
||
@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 | ||
public void onSaveInstanceState(Bundle outState) { | ||
super.onSaveInstanceState(outState); | ||
mapView.onSaveInstanceState(outState); | ||
} | ||
|
||
@Override | ||
public void onLowMemory() { | ||
super.onLowMemory(); | ||
mapView.onLowMemory(); | ||
} | ||
|
||
@Override | ||
public void onDestroy() { | ||
super.onDestroy(); | ||
mapView.onDestroy(); | ||
} | ||
} |
12 changes: 0 additions & 12 deletions
12
platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_circle.xml
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
...form/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_add_remove_marker.xml
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
...form/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_zoom_symbol_layer.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?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" | ||
android:orientation="vertical"> | ||
|
||
<com.mapbox.mapboxsdk.maps.MapView | ||
android:id="@id/mapView" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
app:mapbox_cameraTargetLat="40.730648" | ||
app:mapbox_cameraTargetLng="-73.993619" | ||
app:mapbox_cameraZoom="11" | ||
app:mapbox_styleUrl="@string/mapbox_style_light"/> | ||
|
||
</RelativeLayout> |
1 change: 0 additions & 1 deletion
1
platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/dimens.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters