Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geolocation import #7

Merged
merged 1 commit into from
Aug 16, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Geolocation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Geolocation API 사용하기
=======================

**소개**
- Geolocation API를 사용해서 샘플 앱을 작성합니다.

**실행 방법**
- Firefox OS Simulator를 이용하여, 구동해 볼 수 있습니다.
85 changes: 85 additions & 0 deletions Geolocation/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="pragma" content="no-cache" />
<title>Geolocation J</title>

<script type="text/javascript">

var wpid;

function $(id){
return document.getElementById( id );
}

function renderRegionName( data ){
var elem = $('region_box');
elem.innerHTML = data.name1 + "|" + data.name2;
}

function getRegion ( position ){
var scriptElem = document.createElement( 'script');
scriptElem.type = 'text/javascript';
scriptElem.charset = 'utf-8';

var url = 'http://apis.daum.net/local/geo/coord2addr?apikey=f7af3967b96f2f6540ba7da6afb4895ec94c1fd5&longitude=' + position.coords.longitude + '&latitude=' + position.coords.latitude + '&format=simple&output=json&callback=renderRegionName&inputCoordSystem=WGS84'
scriptElem.src = url;
document.body.appendChild( scriptElem );
}

function showGeoPosition ( latitude, longitude ){
var showbox = $( 'geo_box' );
if ( showbox ){
showbox.innerHTML = "latitude : " + latitude + ", longitude : " + longitude;
}
}

function showError( msg ){
var showbox = $( 'geo_box' );
if ( showbox ){
showbox.innerHTML = msg;
}
}

function geo_success( position ) {
showGeoPosition( position.coords.latitude, position.coords.longitude );
getRegion ( position );
}

function geo_error (){
showError( "현재 위치값을 받아올 수 없습니다");
}

var geo_options = {
enableHighAccuracy : true,
maximumAge : 30000,
time : 27000
}

window.addEventListener('load', function(e) {
wpid = navigator.geolocation.watchPosition( geo_success, geo_error, geo_options );
});

</script>

<style type="text/css">
#get_cur_geo { text-align:center; margin-top:20px;}
#geo_box { text-align:center; margin-top:20px;}
#region_box { text-align:center; margin-top:20px;}
</style>
</head>

<body>
<div id="container">
<div id="get_cur_geo">
현재 위치 받아오기
</div>

<div id="geo_box" > </div>
<div id="region_box"> </div>

</div>
</body>
</html>

38 changes: 38 additions & 0 deletions Geolocation/manifest.webapp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "J Geolocation",
"description": "Geolocation Sample by J Team",
"type": "certified",
"launch_path": "/index.html",
"developer": {
"name": "The Gaia Team J",
"url": "https://github.com/mozilla-b2g/gaia"
},
"permissions": {
"storage":{},
"settings":{ "access": "readonly" },
"geolocation": {}
},
"locales": {
"ar": {
"name": "Geolocation",
"description": "Gaia Geolocation"
},
"en-US": {
"name": "J Geolocation",
"description": "Gaia Geolocation"
},
"fr": {
"name": "Gelocation",
"description": "Gaia Geolocation"
},
"ko": {
"name": "지오로케이션",
"description": "지오로케이션"
}
},
"default_locale": "ko",
"icons": {
"128": "/style/geo_icon.png"
},
"orientation": "portrait-primary"
}