0
1

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 5 years have passed since last update.

Google GeocodingAPIを使ってスポット位置情報一覧のjsonファイルを作成する。

0
Last updated at Posted at 2018-07-07

目的

  • いい感じのスポット(緯度経度)jsonファイルを作成してWebサービスで利用する。

Google Geocoding APIのキーを取得

  • Googleアカウントでプロジェクトを作成してAPIを有効にする。

githubからクローン

git clone git@github.com:niiyz/spots.git

.envファイルを作成してGeocoding APIのキーを設定

cd spots
touch .env
.env
GEO_CODING_API_KEY=vvvvvvvvvvvvvvvvvvvvvvvvvvvvv
GEO_CODING_LANGUAGE=ja

地名一覧を設置

  • 緯度経度を取得したい地名のファイルを設置する。
  • 無料プランでAPI制限が1IPにつき1日2500回なので2500行以内にしておく。
touch list.txt
list.txt
黒部ダム
相倉合掌造り集落
雨晴海岸
砺波チューリップ公園
富山県美術館
高岡古城公園
黒部峡谷
高岡大仏
富士城址公園
海王丸パーク
宇奈月温泉
金太郎温泉
ほたるいかミュージアム

実行


% go run main.go list.txt
float64(36.56644989999999) float64(137.6621042) 日本、〒930-1406 富山県中新川郡立山町芦峅寺 芦峅寺
float64(36.4271101) float64(136.9362354) 日本、〒939-1915 富山県南砺市相倉611 611
float64(36.814949) float64(137.0418846) 日本、富山県高岡市松田江長浜 長浜
float64(36.6397544) float64(136.9610392) 日本、〒939-1382 富山県砺波市花園町1−32 砺波チューリップ公園 砺波チューリップ公園
float64(36.7110268) float64(137.2104677) 日本、〒930-0806 富山県富山市木場町3−20 20
float64(36.7486659) float64(137.0214822) 日本、〒933-0044 富山県高岡市古城1−9 高岡古城公園 高岡古城公園
float64(36.815039) float64(137.585946) 日本、〒938-0283 富山県黒部市黒部峡谷口11 11
float64(36.7456335) float64(137.017054) 日本、〒933-0039 富山県高岡市大手町11 高岡大仏 高岡大仏
float64(35.3605555) float64(138.7277777) 日本、〒418-0112 静岡県富士宮市北山 富士山 富士山
float64(36.7802049) float64(137.1097458) 日本、〒934-0023 富山県射水市海王町8 8
float64(36.8180314) float64(137.5801466) 日本、〒938-0282 富山県黒部市 宇奈月温泉22-1 黒部市
float64(36.8395004) float64(137.4365651) 日本、〒937-0013 富山県魚津市 天神野新6000 魚津市
float64(36.7742797) float64(137.3445045) 日本、〒936-0021 富山県滑川市中川原410 410

jsonファイルを出力

spots.json
[
    {
        "name": "黒部ダム",
        "address": "日本、〒930-1406 富山県中新川郡立山町芦峅寺",
        "lat": 36.56644989999999,
        "lng": 137.6621042
    },
    {
        "name": "相倉合掌造り集落",
        "address": "日本、〒939-1915 富山県南砺市相倉611",
        "lat": 36.4271101,
        "lng": 136.9362354
    },
    {
        "name": "雨晴海岸",
        "address": "日本、富山県高岡市松田江長浜",
        "lat": 36.814949,
        "lng": 137.0418846
    },
    {
        "name": "砺波チューリップ公園",
        "address": "日本、〒939-1382 富山県砺波市花園町1−32 砺波チューリップ公園",
        "lat": 36.6397544,
        "lng": 136.9610392
    },
    {
        "name": "富山県美術館",
        "address": "日本、〒930-0806 富山県富山市木場町3−20",
        "lat": 36.7110268,
        "lng": 137.2104677
    },
    {
        "name": "高岡古城公園",
        "address": "日本、〒933-0044 富山県高岡市古城1−9 高岡古城公園",
        "lat": 36.7486659,
        "lng": 137.0214822
    },
    {
        "name": "黒部峡谷",
        "address": "日本、〒938-0283 富山県黒部市黒部峡谷口11",
        "lat": 36.815039,
        "lng": 137.585946
    },
    {
        "name": "高岡大仏",
        "address": "日本、〒933-0039 富山県高岡市大手町11 高岡大仏",
        "lat": 36.7456335,
        "lng": 137.017054
    },
    {
        "name": "富士城址公園",
        "address": "日本、〒418-0112 静岡県富士宮市北山 富士山",
        "lat": 35.3605555,
        "lng": 138.7277777
    },
    {
        "name": "海王丸パーク",
        "address": "日本、〒934-0023 富山県射水市海王町8",
        "lat": 36.7802049,
        "lng": 137.1097458
    },
    {
        "name": "宇奈月温泉",
        "address": "日本、〒938-0282 富山県黒部市 宇奈月温泉22-1",
        "lat": 36.8180314,
        "lng": 137.5801466
    },
    {
        "name": "金太郎温泉",
        "address": "日本、〒937-0013 富山県魚津市 天神野新6000",
        "lat": 36.8395004,
        "lng": 137.4365651
    },
    {
        "name": "ほたるいかミュージアム",
        "address": "日本、〒936-0021 富山県滑川市中川原410",
        "lat": 36.7742797,
        "lng": 137.3445045
    }
]
0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?