Merged release-0.7.9 into master
commit
27763de2ae
|
@ -1,7 +1,14 @@
|
|||
# Tracman Server Changelog
|
||||
###### v 0.7.8
|
||||
###### v 0.7.9
|
||||
|
||||
|
||||
#### v0.7.9
|
||||
* Updated packages
|
||||
* Added support for browser geolocation
|
||||
* Fixed streetview image bugs
|
||||
* Added sourcemaps for debugging
|
||||
* Fixed streetview bearing
|
||||
|
||||
#### v0.7.8
|
||||
* [#96](https://github.com/Tracman-org/Server/issues/96) Replaced panorama with static images
|
||||
|
||||
|
|
20
README.md
20
README.md
|
@ -1,5 +1,5 @@
|
|||
# <img align="left" src="/static/img/icon/by/48.png" alt="[]" title="The Tracman Logo">Tracman
|
||||
###### v 0.7.8
|
||||
###### v 0.7.9
|
||||
|
||||
node.js application to display a sharable map with user's location.
|
||||
|
||||
|
@ -52,6 +52,13 @@ Tracman will be updated according to [this branching model](http://nvie.com/post
|
|||
|
||||
[view full changelog](CHANGELOG.md)
|
||||
|
||||
#### v0.7.9
|
||||
* Updated packages
|
||||
* Added support for browser geolocation
|
||||
* Fixed streetview image bugs
|
||||
* Added sourcemaps for debugging
|
||||
* Fixed streetview bearing
|
||||
|
||||
#### v0.7.8
|
||||
* [#96](https://github.com/Tracman-org/Server/issues/96) Replaced panorama with static images
|
||||
|
||||
|
@ -77,16 +84,7 @@ Tracman will be updated according to [this branching model](http://nvie.com/post
|
|||
* Added more debugging to fix auth problems
|
||||
|
||||
#### v0.7.0
|
||||
* More bug fixes
|
||||
|
||||
#### v0.6.0-7
|
||||
* Removed demo recording code
|
||||
* Moved email server settings to env file
|
||||
* Added SMTP check
|
||||
* Minified static files
|
||||
* Fixed error when creating user
|
||||
* Removed extraneous packages
|
||||
* Fixed [#87](https://github.com/Tracman-org/Server/issues/87), [#96](https://github.com/Tracman-org/Server/issues/96), [#92](https://github.com/Tracman-org/Server/issues/92), [#84](https://github.com/Tracman-org/Server/issues/84), [#76](https://github.com/Tracman-org/Server/issues/76), [#77](https://github.com/Tracman-org/Server/issues/77), [#32](https://github.com/Tracman-org/Server/issues/32), [#57](https://github.com/Tracman-org/Server/issues/57), [#58](https://github.com/Tracman-org/Server/issues/58), [#60](https://github.com/Tracman-org/Server/issues/60), [#50](https://github.com/Tracman-org/Server/issues/50), [#51](https://github.com/Tracman-org/Server/issues/51), [#52](https://github.com/Tracman-org/Server/issues/52), [#54](https://github.com/Tracman-org/Server/issues/54), [#55](https://github.com/Tracman-org/Server/issues/55), [#61](https://github.com/Tracman-org/Server/issues/61), [#62](https://github.com/Tracman-org/Server/issues/62)
|
||||
* Bug fixes
|
||||
|
||||
|
||||
## License
|
||||
|
|
File diff suppressed because it is too large
Load Diff
28
package.json
28
package.json
|
@ -1,42 +1,42 @@
|
|||
{
|
||||
"name": "tracman",
|
||||
"version": "0.7.8",
|
||||
"version": "0.7.9",
|
||||
"description": "Tracks user's GPS location",
|
||||
"main": "server.js",
|
||||
"dependencies": {
|
||||
"bcrypt": "^1.0.2",
|
||||
"body-parser": "^1.17.2",
|
||||
"bcrypt": "^1.0.3",
|
||||
"body-parser": "^1.18.2",
|
||||
"connect-flash-plus": "^0.2.1",
|
||||
"cookie-parser": "^1.4.3",
|
||||
"cookie-session": "^2.0.0-beta.2",
|
||||
"css-loader": "^0.28.4",
|
||||
"debug": "^2.6.8",
|
||||
"express": "^4.15.3",
|
||||
"express-validator": "^3.2.0",
|
||||
"css-loader": "^0.28.7",
|
||||
"debug": "^2.6.9",
|
||||
"express": "^4.15.5",
|
||||
"express-validator": "^3.2.1",
|
||||
"jquery": "^3.2.1",
|
||||
"load-google-maps-api": "^1.0.0",
|
||||
"minifier": "^0.8.1",
|
||||
"moment": "^2.18.1",
|
||||
"mongoose": "^4.11.0",
|
||||
"mongoose-unique-validator": "^1.0.5",
|
||||
"nodemailer": "^4.0.1",
|
||||
"mongoose": "^4.11.13",
|
||||
"mongoose-unique-validator": "^1.0.6",
|
||||
"nodemailer": "^4.1.1",
|
||||
"nunjucks": "^3.0.1",
|
||||
"passport": "^0.3.2",
|
||||
"passport-facebook": "^2.1.1",
|
||||
"passport-facebook-token": "^3.3.0",
|
||||
"passport-google-id-token": "^0.4.1",
|
||||
"passport-google-id-token": "^0.4.3",
|
||||
"passport-google-oauth20": "^1.0.0",
|
||||
"passport-local": "^1.0.0",
|
||||
"passport-twitter": "^1.0.4",
|
||||
"passport-twitter-token": "^1.3.0",
|
||||
"request": "^2.81.0",
|
||||
"request": "^2.82.0",
|
||||
"slug": "^0.9.1",
|
||||
"socket.io": "^2.0.3",
|
||||
"socket.io-client": "^2.0.3",
|
||||
"style-loader": "^0.18.2",
|
||||
"uglifyjs-webpack-plugin": "^0.4.6",
|
||||
"webpack": "^3.0.0",
|
||||
"xss": "^0.3.3",
|
||||
"webpack": "^3.6.0",
|
||||
"xss": "^0.3.4",
|
||||
"zxcvbn": "^4.4.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
115
static/js/map.js
115
static/js/map.js
|
@ -6,16 +6,14 @@ import $ from 'jquery';
|
|||
import loadGoogleMapsAPI from 'load-google-maps-api';
|
||||
|
||||
// Variables
|
||||
var map, view, marker, elevator, newLoc;
|
||||
var map, marker, elevator, newLoc;
|
||||
const mapElem = document.getElementById('map'),
|
||||
viewElem = document.getElementById('view'),
|
||||
viewImgElem = document.getElementById('viewImg'),
|
||||
socket = io('//'+window.location.hostname);
|
||||
|
||||
// socket.io stuff
|
||||
socket
|
||||
.on('connect', function(){
|
||||
console.log("⬆️ Connected!");
|
||||
//console.log("⬆️ Connected!");
|
||||
|
||||
// Can get location
|
||||
socket.emit('can-get', mapuser._id );
|
||||
|
@ -27,7 +25,7 @@ socket
|
|||
|
||||
})
|
||||
.on('disconnect', function(){
|
||||
console.log("⬇️ Disconnected!");
|
||||
//console.log("⬇️ Disconnected!");
|
||||
})
|
||||
.on('error', function (err){
|
||||
console.error('❌️',err.message);
|
||||
|
@ -60,8 +58,12 @@ loadGoogleMapsAPI({ key:mapKey })
|
|||
|
||||
// Create map and marker elements
|
||||
map = new googlemaps.Map( mapElem, {
|
||||
center: new googlemaps.LatLng( mapuser.last.lat, mapuser.last.lon ),
|
||||
center: {
|
||||
lat: mapuser.last.lat,
|
||||
lng: mapuser.last.lon
|
||||
},
|
||||
panControl: false,
|
||||
scrollwheel: true,
|
||||
scaleControl: (mapuser.settings.showScale)?true:false,
|
||||
draggable: false,
|
||||
zoom: mapuser.settings.defaultZoom,
|
||||
|
@ -119,8 +121,8 @@ loadGoogleMapsAPI({ key:mapKey })
|
|||
|
||||
// Create altitude block
|
||||
if (mapuser.settings.showAlt) {
|
||||
const elevator = new googlemaps.ElevationService,
|
||||
altitudeSign = document.createElement('div'),
|
||||
elevator = new googlemaps.ElevationService;
|
||||
const altitudeSign = document.createElement('div'),
|
||||
altitudeLabel = document.createElement('div'),
|
||||
altitudeText = document.createElement('div'),
|
||||
altitudeUnit = document.createElement('div');
|
||||
|
@ -130,9 +132,7 @@ loadGoogleMapsAPI({ key:mapKey })
|
|||
altitudeSign.id = 'alt-sign';
|
||||
altitudeText.innerHTML = '';
|
||||
altitudeLabel.innerHTML = 'ALTITUDE';
|
||||
getAltitude(new googlemaps.LatLng(mapuser.last.lat,mapuser.last.lon), elevator, function(alt) {
|
||||
if (alt) { altitudeText.innerHTML = (mapuser.settings.units=='standard')?(alt*3.28084).toFixed():alt.toFixed(); }
|
||||
});
|
||||
altitudeText.innerHTML = parseAlt(mapuser.last);
|
||||
altitudeUnit.innerHTML = (mapuser.settings.units=='standard')?'feet':'meters';
|
||||
altitudeSign.appendChild(altitudeLabel);
|
||||
altitudeSign.appendChild(altitudeText);
|
||||
|
@ -147,20 +147,58 @@ loadGoogleMapsAPI({ key:mapKey })
|
|||
updateStreetView(parseLoc(mapuser.last),10);
|
||||
}
|
||||
|
||||
// Parse altitude
|
||||
function parseAlt(loc){
|
||||
|
||||
// Convert to feet if needed
|
||||
function convertUnits(meters){
|
||||
return (mapuser.settings.units=='standard')? (meters*3.28084).toFixed(): meters.toFixed();
|
||||
}
|
||||
|
||||
// Check if altitude was provided
|
||||
if (typeof loc.alt=='number'){
|
||||
return convertUnits(loc.alt);
|
||||
}
|
||||
|
||||
// No altitude provided
|
||||
else {
|
||||
|
||||
// Query google altitude API
|
||||
elevator = elevator || new googlemaps.ElevationService;
|
||||
return elevator.getElevationForLocations({
|
||||
'locations': [{ lat:loc.lat, lng:loc.lon }]
|
||||
}, function(results, status, error_message) {
|
||||
|
||||
// Success; return altitude
|
||||
if (status === googlemaps.ElevationStatus.OK && results[0]) {
|
||||
return convertUnits(results[0].elevation);
|
||||
}
|
||||
|
||||
// Unable to get any altitude
|
||||
else {
|
||||
console.error("Failed to get altitude from API:",status);
|
||||
return "????";
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Parse location
|
||||
function parseLoc(loc) {
|
||||
loc.spd = (mapuser.settings.units=='standard')?parseFloat(loc.spd)*2.23694:parseFloat(loc.spd);
|
||||
loc.dir = parseFloat(loc.dir);
|
||||
loc.lat = parseFloat(loc.lat);
|
||||
loc.lon = parseFloat(loc.lon);
|
||||
loc.alt = parseAlt(loc);
|
||||
loc.tim = new Date(loc.tim).toLocaleString();
|
||||
loc.glatlng = new googlemaps.LatLng(loc.lat, loc.lon);
|
||||
return loc;
|
||||
}
|
||||
|
||||
// Got location
|
||||
socket.on('get', function(loc) {
|
||||
console.log("🌐️ Got location:",loc.lat+", "+loc.lon);
|
||||
//console.log("🌐️ Got location:",loc.lat+", "+loc.lon);
|
||||
|
||||
// Parse location
|
||||
newLoc = parseLoc(loc);
|
||||
|
@ -183,14 +221,7 @@ loadGoogleMapsAPI({ key:mapKey })
|
|||
|
||||
// Update altitude
|
||||
if (mapuser.settings.showAlt) {
|
||||
getAltitude({
|
||||
lat: newLoc.lat,
|
||||
lng: newLoc.lon
|
||||
}, elevator, function(alt) {
|
||||
if (alt) {
|
||||
$('#alt').text( (mapuser.settings.units=='standard')?(alt*3.28084).toFixed():alt.toFixed() );
|
||||
}
|
||||
});
|
||||
$('#alt').text( parseAlt(newLoc) );
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -202,18 +233,6 @@ loadGoogleMapsAPI({ key:mapKey })
|
|||
|
||||
});
|
||||
|
||||
// Check altitude
|
||||
function getAltitude(loc,elev,cb){
|
||||
elev = elev || new googlemaps.ElevationService;
|
||||
elev.getElevationForLocations({
|
||||
'locations': [loc]
|
||||
}, function(results, status) {
|
||||
if (status === googlemaps.ElevationStatus.OK && results[0]) {
|
||||
cb(results[0].elevation);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Get street view imagery
|
||||
function getStreetViewData(loc,rad,cb) {
|
||||
// Ensure that the location hasn't changed (or this is the initial setting)
|
||||
|
@ -246,17 +265,37 @@ loadGoogleMapsAPI({ key:mapKey })
|
|||
function updateStreetView(loc) {
|
||||
|
||||
// Calculate bearing between user and position of streetview image
|
||||
// https://stackoverflow.com/a/26609687/3006854
|
||||
function getBearing(userLoc, imageLoc) {
|
||||
return Math.atan(
|
||||
(userLoc.lon-imageLoc.latLng.lng())
|
||||
/ (userLoc.lat-imageLoc.latLng.lat())
|
||||
) * (180/Math.PI);
|
||||
return 90-(
|
||||
Math.atan2( userLoc.lat-imageLoc.latLng.lat(), userLoc.lon-imageLoc.latLng.lng() )
|
||||
* (180/Math.PI) ) % 360;
|
||||
}
|
||||
|
||||
// Get dimensions for sv request (images proportional to element up to 640x640)
|
||||
function getDimensions(element) {
|
||||
|
||||
// Window is smaller than max
|
||||
if ( element.width()<640 && element.height()<640 ){
|
||||
return element.width().toFixed()+'x'+element.height().toFixed();
|
||||
}
|
||||
|
||||
// Width must be made proportional to 640
|
||||
else if (element.width()>element.height()) {
|
||||
return '640x'+(element.height()*640/element.width()).toFixed();
|
||||
}
|
||||
|
||||
// Height must be made proportional to 640
|
||||
else {
|
||||
return (element.width()*640/element.height()).toFixed()+'x640';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Set image
|
||||
getStreetViewData(loc, 2, function(data){
|
||||
$('#viewImg').attr('src','https://maps.googleapis.com/maps/api/streetview?'+
|
||||
'size='+ $('#view').width() +'x'+ $('#view').height() +
|
||||
'size='+ getDimensions($('#view')) +
|
||||
'&location='+ data.location.latLng.lat() +','+ data.location.latLng.lng() +
|
||||
'&fov=90' + // Inclination
|
||||
// Show direction if moving, point to user if stationary
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
{% endif %}
|
||||
|
||||
<div id='map'></div>
|
||||
<div id='view'><img id='viewImg' alt="Streetview image"></div>
|
||||
<div id='view'><img id='viewImg' alt="Streetview image"/></div>
|
||||
|
||||
<div id='notset' class='centered alert alert-warning'>
|
||||
{% if user.id == mapuser.id %}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
const path = require('path'),
|
||||
env = require('./config/env/env.js'),
|
||||
uglifyJsPlugin = require('uglifyjs-webpack-plugin');
|
||||
|
||||
module.exports = {
|
||||
|
@ -16,6 +17,9 @@ module.exports = {
|
|||
password: './static/js/password.js'
|
||||
},
|
||||
|
||||
// Sourcemaps
|
||||
devtool: (env.mode=='development')?'inline-source-map':false,
|
||||
|
||||
// Output format
|
||||
output: {
|
||||
filename: '.[name].bun.js',
|
||||
|
@ -25,6 +29,6 @@ module.exports = {
|
|||
plugins: [
|
||||
// Minimize JS
|
||||
new uglifyJsPlugin()
|
||||
],
|
||||
]
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue