-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
민창현
committed
Aug 16, 2013
1 parent
df07e99
commit f46087c
Showing
3 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Geolocation API 사용하기 | ||
======================= | ||
|
||
**소개** | ||
- Geolocation API를 사용해서 샘플 앱을 작성합니다. | ||
|
||
**실행 방법** | ||
- Firefox OS Simulator를 이용하여, 구동해 볼 수 있습니다. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |