LoginSignup
6
6

More than 5 years have passed since last update.

Geocodeサービスを使った住所→緯度経度変換処理

Posted at

Google Geocodeでは規約違反になるらしいので、Yahoo!ジオコーダAPIを利用

var request = require('request');

var geocodeURI = 'http://geo.search.olp.yahooapis.jp/OpenLocalPlatform/V1/geoCoder?';
var address = process.argv[2];
if(!address){
    console.log('Not Found address')
    return ;
}
geocodeURI += "&appid=" + "アプリケーションID"; //Yahooデベロッパーネットワークで取得
geocodeURI += "&output=json";
geocodeURI += "&query=" +encodeURI(address.toString("utf8"));

console.log(geocodeURI);

request(geocodeURI, function (error, response, body) {
  if (!error && response.statusCode == 200) {
    var  json = JSON.parse(body);
    console.log(json)
  }
});

実行

 node geocode.js 高崎市

6
6
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
6
6