diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index ad421fd0..3f23627e 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -32,4 +32,6 @@
+
+
diff --git a/android/app/src/main/java/fr/ign/geoportail/MainActivity.java b/android/app/src/main/java/fr/ign/geoportail/MainActivity.java
index 6db6e7c0..04a366b5 100644
--- a/android/app/src/main/java/fr/ign/geoportail/MainActivity.java
+++ b/android/app/src/main/java/fr/ign/geoportail/MainActivity.java
@@ -1,5 +1,20 @@
package fr.ign.geoportail;
+import android.os.Bundle;
+import android.webkit.WebView;
+
import com.getcapacitor.BridgeActivity;
-public class MainActivity extends BridgeActivity {}
+public class MainActivity extends BridgeActivity {
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ }
+
+ @Override
+ public void onStart() {
+ super.onStart();
+ WebView webview = getBridge().getWebView();
+ webview.setOverScrollMode(WebView.OVER_SCROLL_NEVER);
+ }
+}
diff --git a/package.json b/package.json
index cda0227a..896e87ea 100644
--- a/package.json
+++ b/package.json
@@ -8,7 +8,9 @@
"build": "webpack --config webpack.config.js",
"build:dev": "webpack --config dev.config.js",
"serve:dev": "webpack-dev-server --config dev.config.js",
- "run:android": "npm run build:dev && npx cap sync && npx cap run android"
+ "run:android": "npm run build:dev && npx cap sync && npx cap run android",
+ "build:android": "npm run build && npx cap sync && cd android && ./gradlew assembleRelease",
+ "build:android:dev": "npm run build:dev && npx cap sync && cd android && ./gradlew"
},
"keywords": [
"ecosystem:capacitor"
diff --git a/src/js/services/location.js b/src/js/services/location.js
index feab3e87..285dc2c7 100644
--- a/src/js/services/location.js
+++ b/src/js/services/location.js
@@ -88,31 +88,29 @@ const moveTo = (coords, zoom=Globals.map.getZoom(), panTo=true, gps=true) => {
* Suit la position de l'utilisateur
*/
const trackLocation = () => {
+ let lastAccuracy = 100000;
Geolocation.checkPermissions().then((status) => {
if (status.location != 'denied') {
- Geolocation.getCurrentPosition({
- maximumAge: 0,
- timeout: 10000,
- enableHighAccuracy: true
- }).then((position) => {
- moveTo({
- lat: position.coords.latitude,
- lon: position.coords.longitude
- }, Math.max(Globals.map.getZoom(), 14));
- }).catch((err) => {
- console.warn(`${err.message}`);
- });
-
+ var firstLocation = true;
Geolocation.watchPosition({
maximumAge: 0,
timeout: 10000,
enableHighAccuracy: true
},
(position) => {
- moveTo({
- lat: position.coords.latitude,
- lon: position.coords.longitude
- }, Globals.map.getZoom(), tracking_active);
+ if (location_active && position && position.coords.accuracy <= Math.max(lastAccuracy, 16) ) {
+ lastAccuracy = position.coords.accuracy;
+ currentPosition = position;
+ var zoom = Globals.map.getZoom();
+ if (firstLocation) {
+ zoom = Math.max(Globals.map.getZoom(), 14);
+ firstLocation = false;
+ }
+ moveTo({
+ lat: position.coords.latitude,
+ lon: position.coords.longitude
+ }, zoom, tracking_active);
+ }
}).then( (watchId) => {
watch_id = watchId
}).catch((err) => {
@@ -168,6 +166,7 @@ const locationOnOff = async () => {
DOM.$geolocateBtn.style.backgroundImage = 'url("' + LocationImg + '")';
Geolocation.clearWatch({id: watch_id});
clean();
+ currentPosition = null;
location_active = false;
tracking_active = false;
Toast.show({
@@ -203,12 +202,15 @@ const getOrientation = (event) => {
*/
const getLocation = async (tracking) => {
var results = null;
- enablePosition(tracking);
- var position = await Geolocation.getCurrentPosition({
- maximumAge: 0,
- timeout: 10000,
- enableHighAccuracy: true
- })
+ var position = currentPosition;
+ if (currentPosition === null) {
+ enablePosition(tracking);
+ var position = await Geolocation.getCurrentPosition({
+ maximumAge: 0,
+ timeout: 10000,
+ enableHighAccuracy: true
+ });
+ }
results = {
coordinates : {