2013-01-12 84 views
0

我是新來的Android和我遇到了一些麻煩試圖讀取該JSON:閱讀JSON從GoogleApis

http://maps.googleapis.com/maps/api/geocode/json?address=portugal&sensor=true

{ 
"results" : [ 
    { 
    "address_components" : [ 
     { 
      "long_name" : "Portugal", 
      "short_name" : "PT", 
      "types" : [ "country", "political" ] 
     } 
    ], 
    "formatted_address" : "Portugal", 
    "geometry" : { 
     "bounds" : { 
      "northeast" : { 
       "lat" : 42.15420480, 
       "lng" : -6.19020910 
      }, 
      "southwest" : { 
       "lat" : 32.403740, 
       "lng" : -31.2751580 
      } 
     }, 
     "location" : { 
      "lat" : 39.39987199999999, 
      "lng" : -8.2244540 
     }, 
     "location_type" : "APPROXIMATE", 
     "viewport" : { 
      "northeast" : { 
       "lat" : 42.15420480, 
       "lng" : -6.19020910 
      }, 
      "southwest" : { 
       "lat" : 36.96017720, 
       "lng" : -9.51711070 
      } 
     } 
    }, 
    "types" : [ "country", "political" ] 
    } 
    ], 
    "status" : "OK" 
} 

任何人都可以點我一些圖書館或一些代碼讓我開始? :d

泰提前

編輯

是可以使用這個結果並顯示在一個活動在谷歌地圖的實際位置?

+0

什麼是本期從谷歌API閱讀JSON或你不能夠解析它的一些例子嗎? –

+0

我是一個新手和IM不能分析它的Android SDK內由xD –

+0

見''org.json''包。有解析和訪問JSON數據的類。 – harism

回答

0

結果[0] .address_components [0] .long_name將輸出葡萄牙

結果[0] .geometry.location.lat將輸出39.39987199999999

等等

可以使用lat和液化天然氣集中在使用map.setCenter該位置(經緯度:經緯度)地圖