得到谷歌地图从JSON坐标 [英] get coordinates from JSON from google maps

查看:124
本文介绍了得到谷歌地图从JSON坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到我的位置,从一个地址,我用这个网站

I'm getting my position from an address, I use this website:

我得到的JSON数据,但我不知道如何在我的Andr​​oid应用程序读取它。

I get JSON data, but I dont know how to read it in my Android app.

{
  "name": "plaza mayor 1 madrid España",

  "Status": {

    "code": 200,

    "request": "geocode"

  },

  "Placemark": [ {

    "id": "p1",

    "address": "Plaza Mayor, 1, 28012 Madrid, España",

    "AddressDetails": {

   "Accuracy" : 8,

   "Country" : {

      "AdministrativeArea" : {

         "AdministrativeAreaName" : "Comunidad de Madrid",

         "SubAdministrativeArea" : {

            "Locality" : {

               "LocalityName" : "Madrid",

               "PostalCode" : {

                  "PostalCodeNumber" : "28012"

               },

               "Thoroughfare" : {

                  "ThoroughfareName" : "Plaza Mayor, 1"

               }

            },

            "SubAdministrativeAreaName" : "Madrid"

         }

      },

      "CountryName" : "España",

      "CountryNameCode" : "ES"

   }

},

    "ExtendedData": {

      "LatLonBox": {

        "north": 40.4164186,

        "south": 40.4137207,

        "east": -3.7053139,

        "west": -3.7080118

      }

    },

    "Point": {

      "coordinates": [ -3.7066379, 40.4150359, 0 ]

    }

  } ]

}

如何能我读了坐标标签?

How can I read the "coordinates" tag?

感谢你在前进!

推荐答案

解析它,首先,然后访问的各种元素:

parse it, to begin with, then access the various elements :

JSONObject response = new JSONObject(responseAsString);
JSONObject point = response.getJSONArray("Placemark").getJSONObject(0).getJSONObject("Point");

double lat = point.getJSONArray("coordinates").getDouble(0);

这篇关于得到谷歌地图从JSON坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆