From a1306fbd3eeceea9e729fe8aa29d5cadf15c340b Mon Sep 17 00:00:00 2001 From: Josh Erb Date: Thu, 2 May 2019 13:30:59 -0400 Subject: [PATCH] setting up initial boilerplate --- .../mapboxandroiddemo/MainActivity.java | 8 ++ .../src/main/AndroidManifest.xml | 7 ++ .../TurfPhysicalCircleActivity.java | 102 ++++++++++++++++++ .../activity_lab_circle_physical_units.xml | 27 +++++ .../main/res/values/descriptions_strings.xml | 1 + .../src/main/res/values/titles_strings.xml | 1 + 6 files changed, 146 insertions(+) create mode 100644 MapboxAndroidDemo/src/main/java/com/mapbox/mapboxandroiddemo/examples/javaservices/TurfPhysicalCircleActivity.java create mode 100644 MapboxAndroidDemo/src/main/res/layout/activity_lab_circle_physical_units.xml diff --git a/MapboxAndroidDemo/src/global/java/com/mapbox/mapboxandroiddemo/MainActivity.java b/MapboxAndroidDemo/src/global/java/com/mapbox/mapboxandroiddemo/MainActivity.java index d342ca211..ebd7bc621 100644 --- a/MapboxAndroidDemo/src/global/java/com/mapbox/mapboxandroiddemo/MainActivity.java +++ b/MapboxAndroidDemo/src/global/java/com/mapbox/mapboxandroiddemo/MainActivity.java @@ -78,6 +78,7 @@ import com.mapbox.mapboxandroiddemo.examples.javaservices.StaticImageActivity; import com.mapbox.mapboxandroiddemo.examples.javaservices.TilequeryActivity; import com.mapbox.mapboxandroiddemo.examples.javaservices.TurfRingActivity; +import com.mapbox.mapboxandroiddemo.examples.javaservices.TurfPhysicalCircleActivity; import com.mapbox.mapboxandroiddemo.examples.labs.AnimatedImageGifActivity; import com.mapbox.mapboxandroiddemo.examples.labs.AnimatedMarkerActivity; import com.mapbox.mapboxandroiddemo.examples.labs.CalendarIntegrationActivity; @@ -1010,6 +1011,13 @@ private void initializeModels() { null, R.string.activity_java_turf_ring_url, false, BuildConfig.MIN_SDK_VERSION )); + exampleItemModels.add(new ExampleItemModel( + R.id.nav_java_services, + R.string.activity_java_services_turf_physical_circle_title, + R.string.activity_java_services_turf_physical_circle_description, + new Intent(MainActivity.this, TurfPhysicalCircleActivity.class), + null, + R.string.activity_java_services_tilequery_url, false, BuildConfig.MIN_SDK_VERSION)); exampleItemModels.add(new ExampleItemModel( R.id.nav_snapshot_image_generator, diff --git a/MapboxAndroidDemo/src/main/AndroidManifest.xml b/MapboxAndroidDemo/src/main/AndroidManifest.xml index 72194dcc3..0ddf7c3ce 100644 --- a/MapboxAndroidDemo/src/main/AndroidManifest.xml +++ b/MapboxAndroidDemo/src/main/AndroidManifest.xml @@ -148,6 +148,13 @@ android:name="android.support.PARENT_ACTIVITY" android:value="com.mapbox.mapboxandroiddemo.MainActivity" /> + + + diff --git a/MapboxAndroidDemo/src/main/java/com/mapbox/mapboxandroiddemo/examples/javaservices/TurfPhysicalCircleActivity.java b/MapboxAndroidDemo/src/main/java/com/mapbox/mapboxandroiddemo/examples/javaservices/TurfPhysicalCircleActivity.java new file mode 100644 index 000000000..6786e968b --- /dev/null +++ b/MapboxAndroidDemo/src/main/java/com/mapbox/mapboxandroiddemo/examples/javaservices/TurfPhysicalCircleActivity.java @@ -0,0 +1,102 @@ +package com.mapbox.mapboxandroiddemo.examples.javaservices; + +import android.graphics.Color; +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.v7.app.AppCompatActivity; +import android.widget.Toast; + +import com.mapbox.mapboxandroiddemo.R; +import com.mapbox.mapboxsdk.Mapbox; +import com.mapbox.mapboxsdk.maps.MapView; +import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; +import com.mapbox.mapboxsdk.maps.Style; +import com.mapbox.mapboxsdk.style.layers.FillLayer; +import com.mapbox.mapboxsdk.style.sources.GeoJsonSource; + +/** + * Use {@link TurfTransformation#circle(Point, double, int, String)} to draw a circle + * at a center coordinate with it's radius specified in physical units (i.e. "miles") + */ +public class TurfPhysicalCircleActivity extends AppCompatActivity { + private MapView mapView; + private MapboxMap mapboxMap; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + + // Mapbox access token is configured here. This needs to be called either in your application + // object or in the same activity which contains the mapview. + Mapbox.getInstance(this, getString(R.string.access_token)); + + // This contains the MapView in XML and needs to be called after the access token is configured. + setContentView(R.layout.activity_lab_circle_physical_units); + + mapView = findViewById(R.id.mapView); + mapView.onCreate(savedInstanceState); + + mapView.getMapAsync(new OnMapReadyCallback() { + @Override + public void onMapReady(@NonNull MapboxMap mapboxMap) { + TurfPhysicalCircleActivity.this.mapboxMap = mapboxMap; + + mapboxMap.setStyle(Style.LIGHT, new Style.OnStyleLoaded() { + @Override + public void onStyleLoaded(@NonNull Style style) { + + // Do example things here + + } + } + ); + } + }); + + } + + // Add the mapView lifecycle to the activity's lifecycle methods + @Override + public void onResume() { + super.onResume(); + mapView.onResume(); + } + + @Override + protected void onStart() { + super.onStart(); + mapView.onStart(); + } + + @Override + protected void onStop() { + super.onStop(); + mapView.onStop(); + } + + @Override + public void onPause() { + super.onPause(); + mapView.onPause(); + } + + @Override + public void onLowMemory() { + super.onLowMemory(); + mapView.onLowMemory(); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + mapView.onDestroy(); + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + mapView.onSaveInstanceState(outState); + } +} diff --git a/MapboxAndroidDemo/src/main/res/layout/activity_lab_circle_physical_units.xml b/MapboxAndroidDemo/src/main/res/layout/activity_lab_circle_physical_units.xml new file mode 100644 index 000000000..61942b08f --- /dev/null +++ b/MapboxAndroidDemo/src/main/res/layout/activity_lab_circle_physical_units.xml @@ -0,0 +1,27 @@ + + + + + + + + \ No newline at end of file diff --git a/MapboxAndroidDemo/src/main/res/values/descriptions_strings.xml b/MapboxAndroidDemo/src/main/res/values/descriptions_strings.xml index e5d002c3c..f3b945a22 100644 --- a/MapboxAndroidDemo/src/main/res/values/descriptions_strings.xml +++ b/MapboxAndroidDemo/src/main/res/values/descriptions_strings.xml @@ -87,6 +87,7 @@ Use the Geocoding API to receive information about specific coordinates. Use the Isochrone API to receive information about how far you can travel within a given time. Use the Tilequery API to search for features in a tileset. This example queries for up to 10 buildings which are within 50 meters of the single map click location. + Use Turf to generate a circle with a radius expressed in physical units (e.g. miles). Use the traffic plugin to display live car congestion data on top of a map. Use the building plugin to easily display 3D building height Easily retrieve GeoJSON data from a url, asset, or path diff --git a/MapboxAndroidDemo/src/main/res/values/titles_strings.xml b/MapboxAndroidDemo/src/main/res/values/titles_strings.xml index 85b854838..8821e1c63 100644 --- a/MapboxAndroidDemo/src/main/res/values/titles_strings.xml +++ b/MapboxAndroidDemo/src/main/res/values/titles_strings.xml @@ -85,6 +85,7 @@ Make a geocode request Make a isochrone request Make a tilequery request + Define a circle in physical units Display real-time traffic Display buildings in 3D Change map text to device language