Skip to content

Instantly share code, notes, and snippets.

@tomo3141592653
Created May 17, 2012 03:10
Show Gist options
  • Save tomo3141592653/2715928 to your computer and use it in GitHub Desktop.
Save tomo3141592653/2715928 to your computer and use it in GitHub Desktop.
今いる住所が分かるアプリ
<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">&nbsp;</div>
<p>にいます。</p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment