Commit dd7a3b2d authored by Chris Scott's avatar Chris Scott

Add new Cordova CSP meta tag. Modify schema of returned geolocation, placing...

Add new Cordova CSP meta tag.  Modify schema of returned geolocation, placing location params into 'coords' key in order to make room for extra meta-data, such as detected-activity from Android
parent 0e3d2ffc
......@@ -24,6 +24,7 @@
<meta name="msapplication-tap-highlight" content="no" />
<!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src * 'unsafe-inline' data:; img-src *; script-src * 'unsafe-inline' 'unsafe-eval'">
<link rel="stylesheet" type="text/css" href="css/bootstrap-min.css" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<title>BG GeoLocation</title>
......
......@@ -162,7 +162,9 @@ var app = {
console.log('[js] BackgroundGeoLocation onStationary ' + JSON.stringify(location));
app.setCurrentLocation(location);
var coords = location.coords;
// Center ourself on map
app.onClickHome();
......@@ -175,7 +177,7 @@ var app = {
});
}
var radius = 50;
var center = new google.maps.LatLng(location.latitude, location.longitude);
var center = new google.maps.LatLng(coords.latitude, coords.longitude);
app.stationaryRadius.setRadius(radius);
app.stationaryRadius.setCenter(center);
......@@ -189,6 +191,7 @@ var app = {
distanceFilter: 50,
disableElasticity: false, // <-- [iOS] Default is 'false'. Set true to disable speed-based distanceFilter elasticity
locationUpdateInterval: 5000,
minimumActivityRecognitionConfidence: 80, // percentage
fastestLocationUpdateInterval: 5000,
activityRecognitionInterval: 10000,
stopTimeout: 0,
......@@ -228,7 +231,7 @@ var app = {
}
var map = app.map,
coords = location.coords,
ll = new google.maps.LatLng(location.latitude, location.longitude),
ll = new google.maps.LatLng(coords.latitude, coords.longitude),
zoom = map.getZoom();
map.setCenter(ll);
......@@ -292,7 +295,7 @@ var app = {
}
// Watch foreground location
app.foregroundWatchId = fgGeo.watchPosition(function(location) {
app.setCurrentLocation(location.coords);
app.setCurrentLocation(location);
});
},
/**
......@@ -329,6 +332,8 @@ var app = {
// Set currentLocation @property
app.currentLocation = location;
var coords = location.coords;
if (!app.currentLocationMarker) {
app.currentLocationMarker = new google.maps.Marker({
map: app.map,
......@@ -346,6 +351,7 @@ var app = {
strokeOpacity: 0,
map: app.map
});
app.onClickHome();
}
if (!app.path) {
app.path = new google.maps.Polyline({
......@@ -354,7 +360,8 @@ var app = {
fillOpacity: 0.4
});
}
var latlng = new google.maps.LatLng(location.latitude, location.longitude);
var latlng = new google.maps.LatLng(coords.latitude, coords.longitude);
if (app.previousLocation) {
var prevLocation = app.previousLocation;
......@@ -368,14 +375,14 @@ var app = {
strokeWeight: 5
},
map: app.map,
position: new google.maps.LatLng(prevLocation.latitude, prevLocation.longitude)
position: new google.maps.LatLng(prevLocation.coords.latitude, prevLocation.coords.longitude)
}));
}
// Update our current position marker and accuracy bubble.
app.currentLocationMarker.setPosition(latlng);
app.locationAccuracyMarker.setCenter(latlng);
app.locationAccuracyMarker.setRadius(location.accuracy);
app.locationAccuracyMarker.setRadius(location.coords.accuracy);
// Add breadcrumb to current Polyline path.
app.path.getPath().push(latlng);
......
......@@ -155,6 +155,9 @@ public class CDVBackgroundGeolocation extends CordovaPlugin {
if (config.has("debug")) {
editor.putBoolean("debug", config.getBoolean("debug"));
}
if (config.has("stopAfterElapsedMinutes")) {
editor.putInt("stopAfterElapsedMinutes", config.getInt("stopAfterElapsedMinutes"));
}
if (config.has("stopOnTerminate")) {
editor.putBoolean("stopOnTerminate", config.getBoolean("stopOnTerminate"));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment