LoginSignup
1
1

More than 5 years have passed since last update.

SpringのRestTemplateを使ってYahoo!ジオコーダAPIから緯度経度を取得する

Last updated at Posted at 2013-06-07

面倒なんでJsonNodeでやっちゃう。

RestTemplate restTemplate = new RestTemplate();
ResponseEntity<JsonNode> response = restTemplate.getForEntity(
        "http://geo.search.olp.yahooapis.jp/OpenLocalPlatform/V1/geoCoder?appid={appId}&query={query}&output={output}",
        JsonNode.class,
        "[YahooのAPIキー]",
        "[検索する住所]",
        "json");

String coordinates = response.getBody().get("Feature").get(0).get("Geometry").get("Coordinates").asText();
1
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
1
1