34
25

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

山手線停車駅の座標一覧

Last updated at Posted at 2014-02-02

一覧

駅名 緯度 経度
東京 35.681382 139.76608399999998
有楽町 35.675069 139.763328
新橋 35.665498 139.75964
浜松町 35.655646 139.756749
田町 35.645736 139.74757499999998
品川 35.630152 139.74044000000004
大崎 35.6197 139.72855300000003
五反田 35.626446 139.72344399999997
目黒 35.633998 139.715828
恵比寿 35.64669 139.710106
渋谷 35.658517 139.70133399999997
原宿 35.670168 139.70268699999997
代々木 35.683061 139.702042
新宿 35.690921 139.70025799999996
新大久保 35.701306 139.70004399999993
高田馬場 35.712285 139.70378200000005
目白 35.721204 139.706587
池袋 35.728926 139.71038
大塚 35.731401 139.72866199999999
巣鴨 35.733492 139.73934499999996
駒込 35.736489 139.74687500000005
田端 35.738062 139.76085999999998
西日暮里 35.732135 139.76678700000002
日暮里 35.727772 139.770987
鶯谷 35.720495 139.77883700000007
上野 35.713768 139.77725399999997
御徒町 35.707438 139.774632
秋葉原 35.698683 139.77421900000002
神田 35.69169 139.77088300000003

コード

index.html
<!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>
main.js
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);

参考サンプル

Geocoding service - Google Maps JavaScript API v3 — Google Developers

宣伝

本記事から着想を受け、技術書典向けに『Google Maps APIで取得する 山手線停車駅の座標』を執筆しました。
Node.jsでの取得方法からGoogle Maspでのピンの設置デモまで記載しています。
あと高輪ゲートウェイ駅も載っています!

34
25
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
34
25

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?