我想要在其中放置位置进行搜索的代码,它将返回纬度和经度。我正在使用谷歌的地理编码 API。我有发送请求等的代码,它返回以下内容:
{"results"=>[{"address_components"=>[{"long_name"=>"London", "short_name"=>"London", "types"=>["locality", "political"]}, {"long_name"=>"United Kingdom", "short_name"=>"GB", "types"=>["country", "political"]}], "formatted_address"=>"London, UK", "geometry"=>{"bounds"=>{"northeast"=>{"lat"=>51.6723432, "lng"=>0.1478797}, "southwest"=>{"lat"=>51.38494009999999, "lng"=>-0.3514683}}, "location"=>{"lat"=>51.51121389999999, "lng"=>-0.1198244}, "location_type"=>"APPROXIMATE", "viewport"=>{"northeast"=>{"lat"=>51.6723432, "lng"=>0.1478797}, "southwest"=>{"lat"=>51.38494009999999, "lng"=>-0.3514683}}}, "types"=>["locality", "political"]}], "status"=>"OK"}
我想从上面的回复中获取 Lat 和 Lng,并将它们分配给两个变量。任何帮助将不胜感激。