Add terrain icon next to weather (closes #4), update and cleanup code to handle it.
Replaced old terrain graphics with new b/w icons.
BIN
res/screen/android/drawable-hdpi/logo.9.png
Normal file
After Width: | Height: | Size: 33 KiB |
BIN
res/screen/android/drawable-mdpi/logo.9.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
res/screen/android/drawable-xhdpi/logo.9.png
Normal file
After Width: | Height: | Size: 51 KiB |
BIN
res/screen/android/drawable-xxhdpi/logo.9.png
Normal file
After Width: | Height: | Size: 78 KiB |
BIN
res/screen/android/drawable-xxxhdpi/logo.9.png
Normal file
After Width: | Height: | Size: 147 KiB |
BIN
www/assets/terrain/-1.png
Normal file
After Width: | Height: | Size: 501 B |
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 752 B |
BIN
www/assets/terrain/1.png
Normal file
After Width: | Height: | Size: 773 B |
BIN
www/assets/terrain/10.png
Normal file
After Width: | Height: | Size: 873 B |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 873 B |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 574 B |
BIN
www/assets/terrain/13.png
Normal file
After Width: | Height: | Size: 453 B |
BIN
www/assets/terrain/2.png
Normal file
After Width: | Height: | Size: 826 B |
Before Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 20 KiB |
BIN
www/assets/terrain/3.png
Normal file
After Width: | Height: | Size: 773 B |
Before Width: | Height: | Size: 21 KiB |
BIN
www/assets/terrain/4.png
Normal file
After Width: | Height: | Size: 826 B |
Before Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 25 KiB |
BIN
www/assets/terrain/5.png
Normal file
After Width: | Height: | Size: 807 B |
Before Width: | Height: | Size: 12 KiB |
BIN
www/assets/terrain/6.png
Normal file
After Width: | Height: | Size: 807 B |
BIN
www/assets/terrain/7.png
Normal file
After Width: | Height: | Size: 740 B |
Before Width: | Height: | Size: 24 KiB |
BIN
www/assets/terrain/8.png
Normal file
After Width: | Height: | Size: 854 B |
Before Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 22 KiB |
BIN
www/assets/terrain/9.png
Normal file
After Width: | Height: | Size: 854 B |
Before Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 26 KiB |
@ -175,6 +175,11 @@ body {
|
|||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#terrainicon {
|
||||||
|
margin-top: -15px;
|
||||||
|
height: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
#energybar-container {
|
#energybar-container {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 30px;
|
top: 30px;
|
||||||
|
@ -18,16 +18,15 @@
|
|||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////
|
//////////////////////////////////////////////
|
||||||
// GPS and terrain stuff
|
// GPS and map stuff
|
||||||
//////////////////////////////////////////////
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles GPS and terrain data.
|
* Handles GPS and map data.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Globals
|
// Globals
|
||||||
var lockGot = false;
|
var lockGot = false;
|
||||||
var terrainGot = false;
|
|
||||||
var latitude = 0.0000;
|
var latitude = 0.0000;
|
||||||
var longitude = 0.0000;
|
var longitude = 0.0000;
|
||||||
var gpsaccuracy = 9999;
|
var gpsaccuracy = 9999;
|
||||||
@ -36,7 +35,6 @@ var requiredaccuracy = 40;
|
|||||||
|
|
||||||
var fetchplacecounter = 0;
|
var fetchplacecounter = 0;
|
||||||
var lastgpstime = 0;
|
var lastgpstime = 0;
|
||||||
var terraintypeid = 0;
|
|
||||||
var map = L.map('map');
|
var map = L.map('map');
|
||||||
var tileurl = "http://tile.stamen.com/terrain/{z}/{x}/{y}.jpg";
|
var tileurl = "http://tile.stamen.com/terrain/{z}/{x}/{y}.jpg";
|
||||||
map.setZoom(17);
|
map.setZoom(17);
|
||||||
@ -176,8 +174,9 @@ function openPlace(feature) {
|
|||||||
* Hide the loading overlay if everything is loaded, otherwise do nothing
|
* Hide the loading overlay if everything is loaded, otherwise do nothing
|
||||||
*/
|
*/
|
||||||
function hideLoading() {
|
function hideLoading() {
|
||||||
if (lockGot && terrainGot && gpsaccuracy < requiredaccuracy && $('#loading').css('display') !== 'none') {
|
if (lockGot && gpsaccuracy < requiredaccuracy && $('#loading').css('display') !== 'none') {
|
||||||
getWeather();
|
getWeather();
|
||||||
|
getTerrain();
|
||||||
$('#loading').fadeOut('slow', function () {
|
$('#loading').fadeOut('slow', function () {
|
||||||
$('#loading').css('display', 'none');
|
$('#loading').css('display', 'none');
|
||||||
updateStatusBarColor();
|
updateStatusBarColor();
|
||||||
@ -197,25 +196,6 @@ var updatePosition = function (position) {
|
|||||||
}
|
}
|
||||||
mapPos(latitude, longitude);
|
mapPos(latitude, longitude);
|
||||||
};
|
};
|
||||||
var updateTerrain = function (position) {
|
|
||||||
latitude = position.coords.latitude;
|
|
||||||
longitude = position.coords.longitude;
|
|
||||||
lastgpstime = position.timestamp;
|
|
||||||
gpsaccuracy = position.coords.accuracy;
|
|
||||||
var rasterurl = "http://earth.apis.netsyms.net/terrain.php?format=json&lat="
|
|
||||||
+ latitude + "&long=" + longitude;
|
|
||||||
$.get(rasterurl, function (data) {
|
|
||||||
if (data.status === 'OK') {
|
|
||||||
terraintypeid = data.typeid;
|
|
||||||
terraintypename = data.typename;
|
|
||||||
$('#terrain-image').attr('src', 'assets/terrain/' + terraintypeid + '.png');
|
|
||||||
terrainGot = true;
|
|
||||||
hideLoading();
|
|
||||||
}
|
|
||||||
}, "json").fail(function (err) {
|
|
||||||
$('#terrain-image').attr('src', 'assets/terrain/0.png');
|
|
||||||
});
|
|
||||||
};
|
|
||||||
function pingServer() {
|
function pingServer() {
|
||||||
if (lockGot && gpsaccuracy < requiredaccuracy) {
|
if (lockGot && gpsaccuracy < requiredaccuracy) {
|
||||||
$.get(mkApiUrl('ping') + "?user=" + username + "&lat=" + latitude + "&long=" + longitude);
|
$.get(mkApiUrl('ping') + "?user=" + username + "&lat=" + latitude + "&long=" + longitude);
|
||||||
@ -231,22 +211,21 @@ function popDiagData() {
|
|||||||
"\nLongitude: " + longitude +
|
"\nLongitude: " + longitude +
|
||||||
"\nAccuracy: " + gpsaccuracy +
|
"\nAccuracy: " + gpsaccuracy +
|
||||||
"\nWeather: " + rawWeatherData.temperature + " F, " + rawWeatherData.summary + ", " + rawWeatherData.windSpeed + " mph" +
|
"\nWeather: " + rawWeatherData.temperature + " F, " + rawWeatherData.summary + ", " + rawWeatherData.windSpeed + " mph" +
|
||||||
"\nTerrain: " + terraintypename + " (" + terraintypeid + ")",
|
"\nTerrain: " + terrainName + " (" + terrainType + ")",
|
||||||
null,
|
null,
|
||||||
"Information",
|
"World Info",
|
||||||
"Close");
|
"Close");
|
||||||
}
|
}
|
||||||
// Initial GPS position and stuff
|
// Initial GPS position and stuff
|
||||||
navigator.geolocation.getCurrentPosition(updateTerrain, onError, {timeout: 10000, enableHighAccuracy: true});
|
navigator.geolocation.getCurrentPosition(updatePosition, onError, {timeout: 10000, enableHighAccuracy: true});
|
||||||
// Update position
|
// Update position
|
||||||
setInterval(function () {
|
setInterval(function () {
|
||||||
navigator.geolocation.getCurrentPosition(updatePosition, onError, {timeout: 10000, enableHighAccuracy: true});
|
navigator.geolocation.getCurrentPosition(updatePosition, onError, {timeout: 10000, enableHighAccuracy: true});
|
||||||
}, 1000);
|
}, 1000);
|
||||||
// Update position + terrain
|
// Update places
|
||||||
setInterval(function () {
|
setInterval(function () {
|
||||||
navigator.geolocation.getCurrentPosition(updateTerrain, onError, {timeout: 10000, enableHighAccuracy: true});
|
|
||||||
loadPlaces(latitude, longitude);
|
loadPlaces(latitude, longitude);
|
||||||
}, 1000 * 20);
|
}, 1000 * 15);
|
||||||
// Ping the server with coordinates
|
// Ping the server with coordinates
|
||||||
setInterval(pingServer, 5000);
|
setInterval(pingServer, 5000);
|
||||||
// Show error if it's taking too long
|
// Show error if it's taking too long
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
//////////////////////////////////////////////
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
var rawWeatherData = [];
|
var rawWeatherData = [];
|
||||||
|
var terrainType = -1;
|
||||||
|
var terrainName = "Other";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Handles general server communication.
|
* Handles general server communication.
|
||||||
@ -82,6 +84,24 @@ function getWeather() {
|
|||||||
var currently = data.currently;
|
var currently = data.currently;
|
||||||
rawWeatherData = currently;
|
rawWeatherData = currently;
|
||||||
skycons.set("weathericon", currently.icon);
|
skycons.set("weathericon", currently.icon);
|
||||||
|
skycons.play();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTerrain() {
|
||||||
|
$.getJSON(mkApiUrl('getterrain'), {
|
||||||
|
lat: latitude,
|
||||||
|
long: longitude
|
||||||
|
}, function (data) {
|
||||||
|
var terrainid = -1;
|
||||||
|
var terrainstr = "Other";
|
||||||
|
if (data.status === "OK") {
|
||||||
|
terrainid = data.type;
|
||||||
|
terrainstr = data.name;
|
||||||
|
}
|
||||||
|
$('#terrainicon').attr('src', 'assets/terrain/' + terrainid + '.png');
|
||||||
|
terrainType = terrainid;
|
||||||
|
terrainName = terrainstr;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,6 +124,7 @@ setInterval(function () {
|
|||||||
}, 3000);
|
}, 3000);
|
||||||
setInterval(function () {
|
setInterval(function () {
|
||||||
getWeather();
|
getWeather();
|
||||||
|
getTerrain();
|
||||||
}, 30 * 1000);
|
}, 30 * 1000);
|
||||||
// Send chat messages
|
// Send chat messages
|
||||||
$("#chatsendform").submit(function (event) {
|
$("#chatsendform").submit(function (event) {
|
||||||
|
@ -43,7 +43,10 @@
|
|||||||
<div id="overlay-top">
|
<div id="overlay-top">
|
||||||
<p id="topbar">
|
<p id="topbar">
|
||||||
<span id="namedisp" onclick="openMenu('profile')"></span>
|
<span id="namedisp" onclick="openMenu('profile')"></span>
|
||||||
<span id="worldinfo" onclick="popDiagData()"><canvas id="weathericon" width="22" height="22"></canvas></span>
|
<span id="worldinfo" onclick="popDiagData()">
|
||||||
|
<canvas id="weathericon" width="22" height="22"></canvas>
|
||||||
|
<img id="terrainicon" src="assets/terrain/-1.png" />
|
||||||
|
</span>
|
||||||
</p>
|
</p>
|
||||||
<div class="progress" id="energybar-container">
|
<div class="progress" id="energybar-container">
|
||||||
<div id="energybar" class="progress-bar" role="progressbar" >
|
<div id="energybar" class="progress-bar" role="progressbar" >
|
||||||
|