Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
26
Help us understand the problem. What is going on with this article?
@butchi_y

山手線停車駅の座標一覧

More than 5 years have passed since last update.
駅名 緯度 経度
東京 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

26
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
butchi_y
博士(工学)のフロントエンドエンジニアです。 ローレベルな言語仕様から、アニメーション演出まで幅広く興味を持ってます。 得意な言語はMathematica、JavaScript、ActionScriptです。 CGや音楽にもそれなりに詳しいです。
kayac
古都鎌倉から新しい技術と面白いサービスを、次々にリリースする面白法人カヤックのフロントエンジニアチーム

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
26
Help us understand the problem. What is going on with this article?