summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authortobrun <tobrun.van.nuland@gmail.com>2015-09-06 16:37:34 +0200
committerJustin R. Miller <incanus@codesorcery.net>2015-09-11 15:12:12 -0700
commitc00687c9327bce4c782962167177c5d6bbf888eb (patch)
tree6a6f518aa999c5a75095cf039bd3d833fb5dc5f4 /android
parent4bdb0e2cc9613255ada077f84b8863c45975dacb (diff)
downloadqtlocation-mapboxgl-c00687c9327bce4c782962167177c5d6bbf888eb.tar.gz
Added "Improve this map" functionality, current zoom level, center latitude and longitude will be parsed in to the url of improve this map.
Diffstat (limited to 'android')
-rw-r--r--android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java22
-rw-r--r--android/java/MapboxGLAndroidSDK/src/main/res/values/arrays.xml2
2 files changed, 18 insertions, 6 deletions
diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java
index 20742ccc1a..5128ed567d 100644
--- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java
+++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/views/MapView.java
@@ -121,6 +121,8 @@ public class MapView extends FrameLayout implements LocationListener {
private static final float DIMENSION_SIXTEEN_DP = 16f;
private static final float DIMENSION_TEN_DP = 10f;
+ private static final int IMPROVE_THIS_MAP_INDEX = 2;
+
/**
* Every annotation that has been added to the map.
*/
@@ -426,7 +428,7 @@ public class MapView extends FrameLayout implements LocationListener {
LayoutParams attrParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
mAttributionsView.setLayoutParams(attrParams);
addView(mAttributionsView);
- mAttributionsView.setOnClickListener(new AttributionOnClickListener());
+ mAttributionsView.setOnClickListener(new AttributionOnClickListener(this));
// Setup Support For Listener Tracking
// MapView's internal listener is setup in onCreate()
@@ -2048,6 +2050,12 @@ public class MapView extends FrameLayout implements LocationListener {
private static class AttributionOnClickListener implements View.OnClickListener, DialogInterface.OnClickListener {
+ private MapView mMapView;
+
+ public AttributionOnClickListener(MapView mapView) {
+ mMapView = mapView;
+ }
+
// Called when someone presses the attribution icon
@Override
public void onClick(View v) {
@@ -2059,13 +2067,17 @@ public class MapView extends FrameLayout implements LocationListener {
builder.show();
}
- // Called when someone selects an attribution
+ // Called when someone selects an attribution, 'Improve this map' adds location data to the url
@Override
public void onClick(DialogInterface dialog, int which) {
- Context context = ((Dialog)dialog).getContext();
- String[]links = context.getResources().getStringArray(R.array.attribution_links);
+ Context context = ((Dialog) dialog).getContext();
+ String url = context.getResources().getStringArray(R.array.attribution_links)[which];
+ if (which == IMPROVE_THIS_MAP_INDEX) {
+ LatLng latLng = mMapView.getCenterCoordinate();
+ url = String.format(url, latLng.getLongitude(), latLng.getLatitude(), (int) mMapView.getZoomLevel());
+ }
Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setData(Uri.parse(links[which]));
+ intent.setData(Uri.parse(url));
context.startActivity(intent);
}
}
diff --git a/android/java/MapboxGLAndroidSDK/src/main/res/values/arrays.xml b/android/java/MapboxGLAndroidSDK/src/main/res/values/arrays.xml
index 3e937722c0..8a8e204b7d 100644
--- a/android/java/MapboxGLAndroidSDK/src/main/res/values/arrays.xml
+++ b/android/java/MapboxGLAndroidSDK/src/main/res/values/arrays.xml
@@ -8,6 +8,6 @@
<array name="attribution_links" formatted="false" translatable="false">
<item>https://www.mapbox.com/about/maps/</item>
<item>http://www.openstreetmap.org/about/</item>
- <item>https://www.mapbox.com/map-feedback</item>
+ <item>https://www.mapbox.com/map-feedback/#/%1$f/%2$f/%3$d</item>
</array>
</resources> \ No newline at end of file