Created
February 2, 2014 09:56
-
-
Save butchi/8765645 to your computer and use it in GitHub Desktop.
山手線停車駅の座標一覧 ref: http://qiita.com/butchi_y/items/3a6b70b38e13dc56ef13
This file contains hidden or 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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>山手座標</title> | |
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script> | |
<script src="main.js"></script> | |
</head> | |
<body> | |
<table class="table-station"> | |
<thead> | |
<tr><th>駅名</th><th>緯度</th><th>経度</th></tr> | |
</thead> | |
<tbody> | |
</tbody> | |
</table> | |
</body> | |
</html> |
This file contains hidden or 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
var geocoder; | |
var stationArr = ['東京','有楽町','新橋','浜松町','田町','品川','大崎','五反田','目黒','恵比寿','渋谷','原宿','代々木','新宿','新大久保','高田馬場','目白','池袋','大塚','巣鴨','駒込','田端','西日暮里','日暮里','鶯谷','上野','御徒町','秋葉原','神田']; | |
var stationLen = stationArr.length; | |
function initialize() { | |
geocoder = new google.maps.Geocoder(); | |
var tbl = document.querySelector('.table-station tbody'); | |
var i=0; | |
getNextStation(); | |
function getNextStation() { | |
geocoder.geocode( { 'address': stationArr[i]+'駅, 東京都'}, function(results, status) { | |
if (status == google.maps.GeocoderStatus.OK) { | |
tbl.innerHTML += '<tr>'+ | |
'<th>'+stationArr[i]+'</th>'+ | |
'<td class="lat">'+results[0].geometry.location.lat()+'</td>'+ | |
'<td class="lng">'+results[0].geometry.location.lng()+'</td>'+ | |
'</tr>'; | |
} else { | |
console.log('Geocode was not successful for the following reason: ' + status); | |
} | |
i++; | |
if(i < stationLen) { | |
// リクエスト制限があるため処理を遅らせる | |
window.setTimeout(function() { | |
getNextStation(); | |
}, 1000); | |
} | |
}); | |
} | |
} | |
google.maps.event.addDomListener(window, 'load', initialize); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment