Created
May 17, 2012 03:10
-
-
Save tomo3141592653/2715928 to your computer and use it in GitHub Desktop.
今いる住所が分かるアプリ
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
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script> | |
<script type="text/javascript">// <![CDATA[ | |
if (navigator.geolocation) { | |
navigator.geolocation.getCurrentPosition(function(position) { | |
//s = position.coords.latitude+","+position.coords.longitude; | |
//document.getElementById('latlng').innerHTML = s; | |
var geocoder; | |
geocoder = new google.maps.Geocoder(); | |
var myLatlng = new google.maps.LatLng(position.coords.latitude,position.coords.longitude) | |
geocoder.geocode({ 'latLng': myLatlng }, function(results, status) { | |
document.getElementById('address').innerHTML = results[0].formatted_address; | |
} | |
); | |
}); | |
} else { | |
alert("I'm sorry, but geolocation services are not supported by your browser."); | |
} | |
// ]]></script> | |
<p>あなたはいま、たぶん、だいたい</p> | |
<div id="address"> </div> | |
<p>にいます。</p> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment