diff --git a/README.md b/README.md
index befd588..e8b3d54 100644
--- a/README.md
+++ b/README.md
@@ -19,20 +19,25 @@ iOS and Android are fully supported.
### iOS
-
-
-
+
+
+
### Android
-
+
## 3. Installation
+npm (latest stable)
+```
+$ cordova plugin add cordova-plugin-mapbox --variable ACCESS_TOKEN=your.access.token
+```
+
+Github master (lastest develop)
```
$ cordova plugin add https://github.com/Telerik-Verified-Plugins/Mapbox --variable ACCESS_TOKEN=your.access.token
-$ cordova prepare
```
Mapbox.js is brought in automatically. There is no need to change or add anything in your html.
diff --git a/package.json b/package.json
index ba0bfcd..4d8357e 100644
--- a/package.json
+++ b/package.json
@@ -1,5 +1,5 @@
{
- "version": "1.1.1",
+ "version": "1.1.2",
"name": "cordova-plugin-mapbox",
"cordova_name": "Mapbox",
"description": "Need native maps? Look no further!",
diff --git a/plugin.xml b/plugin.xml
index aba01b7..4173990 100755
--- a/plugin.xml
+++ b/plugin.xml
@@ -2,7 +2,7 @@
+ version="1.1.2">
Mapbox
diff --git a/src/android/Mapbox.java b/src/android/Mapbox.java
index 44dce97..854ba01 100644
--- a/src/android/Mapbox.java
+++ b/src/android/Mapbox.java
@@ -3,15 +3,14 @@
import android.Manifest;
import android.content.pm.PackageManager;
import android.content.res.Resources;
+import android.os.Build;
+import android.support.v4.app.ActivityCompat;
+import android.support.v4.content.ContextCompat;
import android.util.DisplayMetrics;
-import android.view.MotionEvent;
-import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
-import com.mapbox.mapboxsdk.constants.MapboxConstants;
import com.mapbox.mapboxsdk.constants.Style;
-import com.mapbox.mapboxsdk.annotations.Annotation;
import com.mapbox.mapboxsdk.annotations.Marker;
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
import com.mapbox.mapboxsdk.annotations.PolygonOptions;
@@ -362,17 +361,32 @@ private static String getStyle(final String requested) {
}
}
+ private boolean permissionGranted(String... types) {
+ if (Build.VERSION.SDK_INT < 23) {
+ return true;
+ }
+ for (final String type : types) {
+ if (PackageManager.PERMISSION_GRANTED != ContextCompat.checkSelfPermission(this.cordova.getActivity(), type)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
protected void showUserLocation() {
- if (cordova.hasPermission(COARSE_LOCATION) && cordova.hasPermission(FINE_LOCATION)) {
+ if (permissionGranted(COARSE_LOCATION, FINE_LOCATION)) {
mapView.setMyLocationEnabled(showUserLocation);
} else {
- getLocationPermission(LOCATION_REQ_CODE);
+ requestPermission(COARSE_LOCATION, FINE_LOCATION);
}
}
- protected void getLocationPermission(int requestCode) {
- String[] permissions = { FINE_LOCATION, COARSE_LOCATION };
- cordova.requestPermissions(this, requestCode, permissions);
+
+ private void requestPermission(String... types) {
+ ActivityCompat.requestPermissions(
+ this.cordova.getActivity(),
+ types,
+ LOCATION_REQ_CODE);
}
public void onRequestPermissionResult(int requestCode, String[] permissions, int[] grantResults) throws JSONException {