Skip to content

Instantly share code, notes, and snippets.

@JoaoGFarias
Created August 15, 2014 12:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoaoGFarias/ca2f5ccbe0ea5e0d2318 to your computer and use it in GitHub Desktop.
Save JoaoGFarias/ca2f5ccbe0ea5e0d2318 to your computer and use it in GitHub Desktop.
Tizen and Google Maps
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta name="description" content="Tizen basic template generated by Tizen Web IDE"/>
<title>Tizen Web IDE - Tizen - Tizen basic Application</title>
<link rel="stylesheet" type="text/css" href="css/style.css"/>
<script src="js/main.js"></script>
</head>
<body>
<form>
<div id="divbutton1">
<!--A button that calls the location function-->
<input type ="button"
id = "mainButton"
onclick="getLocation()"
value = "Get Location"></input>
</div>
<!--The results comes here-->
<div id = "location"></div>
</form>
<footer>
<p>&copy; 2012 Company Name. All rights reserved.</p>
</footer>
</body>
</html>
// This function uses the Google Maps API to get location
function getLocation(){
navigator.geolocation.getCurrentPosition(function(position) {
document.getElementById('location').innerHTML = "Latitude: " + position.coords.latitude +
" Longitude: " + position.coords.longitude;
}, function(error) {
document.getElementById('location').innerHTML ="GPS error occurred";
});
// Below are Tizen default functions; not relevant
var startTime;
var checkTime;
//Initialize function
var init = function () {
// TODO:: Do your initialization job
console.log("init() called");
// add eventListener for tizenhwkey
document.addEventListener('tizenhwkey', function(e) {
if(e.keyName == "back")
tizen.application.getCurrentApplication().exit();
});
};
// window.onload can work without <body onload="">
window.onload = init;
function startTime() {
var today = new Date();
var h = today.getHours();
var m = today.getMinutes();
var s = today.getSeconds();
m = checkTime(m);
s = checkTime(s);
document.getElementById('divbutton1').innerHTML="Current time: " + h + ":" + m + ":" + s;
t = setTimeout(startTime, 250);
}
function checkTime(i) {
if (i < 10) {
i="0" + i;
}
return i;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment