根据经纬度根据谷歌地图接口获取到当前地址

/*http://maps.google.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true */

上面的访问地址国内可能无法访问,国内可以访问以下地址

 

String url = "http://maps.google.cn/maps/api/geocode/json?latlng="+latitude+","+longitude+"&sensor=true&language=zh-CN";
//latitude 纬度 //longitude 经度   

例如:
http://maps.google.cn/maps/api/geocode/json?latlng=31.094668243086,121.21736204624&sensor=true&language=zh-CN

 

以下是返回的json数据
 
 
{
    "results": [
        {
            "address_components": [
                {
                    "long_name": "888",
                    "short_name": "888",
                    "types": [
                        "street_number"
                    ]
                },
                {
                    "long_name": "林湖路",
                    "short_name": "林湖路",
                    "types": [
                        "route"
                    ]
                },
                {
                    "long_name": "松江区",
                    "short_name": "松江区",
                    "types": [
                        "political",
                        "sublocality",
                        "sublocality_level_1"
                    ]
                },
                {
                    "long_name": "上海市",
                    "short_name": "上海市",
                    "types": [
                        "locality",
                        "political"
                    ]
                },
                {
                    "long_name": "上海市",
                    "short_name": "上海市",
                    "types": [
                        "administrative_area_level_1",
                        "political"
                    ]
                },
                {
                    "long_name": "中国",
                    "short_name": "CN",
                    "types": [
                        "country",
                        "political"
                    ]
                }
            ],
            "formatted_address": "中国上海市松江区林湖路888号",
            "geometry": {
                "location": {
                    "lat": 31.093379,
                    "lng": 121.217555
                },
                "location_type": "ROOFTOP",
                "viewport": {
                    "northeast": {
                        "lat": 31.0947279802915,
                        "lng": 121.2189039802915
                    },
                    "southwest": {
                        "lat": 31.0920300197085,
                        "lng": 121.2162060197085
                    }
                }
            },
            "place_id": "ChIJ77t1mgr1sjUR8FQ6cZVYTAI",
            "types": [
                "street_address"
            ]
        },
        {
            "address_components": [
                {
                    "long_name": "松江区",
                    "short_name": "松江区",
                    "types": [
                        "political",
                        "sublocality",
                        "sublocality_level_1"
                    ]
                },
                {
                    "long_name": "上海市",
                    "short_name": "上海市",
                    "types": [
                        "locality",
                        "political"
                    ]
                },
                {
                    "long_name": "上海市",
                    "short_name": "上海市",
                    "types": [
                        "administrative_area_level_1",
                        "political"
                    ]
                },
                {
                    "long_name": "中国",
                    "short_name": "CN",
                    "types": [
                        "country",
                        "political"
                    ]
                }
            ],
            "formatted_address": "中国上海市松江区",
            "geometry": {
                "bounds": {
                    "northeast": {
                        "lat": 31.1629344,
                        "lng": 121.3723276
                    },
                    "southwest": {
                        "lat": 30.8943398,
                        "lng": 121.0248826
                    }
                },
                "location": {
                    "lat": 31.032243,
                    "lng": 121.227747
                },
                "location_type": "APPROXIMATE",
                "viewport": {
                    "northeast": {
                        "lat": 31.1629344,
                        "lng": 121.3723276
                    },
                    "southwest": {
                        "lat": 30.8943398,
                        "lng": 121.0248826
                    }
                }
            },
            "place_id": "ChIJOzMSRxPzsjURTD7MqSppnco",
            "types": [
                "political",
                "sublocality",
                "sublocality_level_1"
            ]
        },
        {
            "address_components": [
                {
                    "long_name": "上海市",
                    "short_name": "上海市",
                    "types": [
                        "locality",
                        "political"
                    ]
                },
                {
                    "long_name": "上海市",
                    "short_name": "上海市",
                    "types": [
                        "administrative_area_level_1",
                        "political"
                    ]
                },
                {
                    "long_name": "中国",
                    "short_name": "CN",
                    "types": [
                        "country",
                        "political"
                    ]
                }
            ],
            "formatted_address": "中国上海市",
            "geometry": {
                "bounds": {
                    "northeast": {
                        "lat": 31.8727163,
                        "lng": 122.2471487
                    },
                    "southwest": {
                        "lat": 30.6755932,
                        "lng": 120.8568046
                    }
                },
                "location": {
                    "lat": 31.2303904,
                    "lng": 121.4737021
                },
                "location_type": "APPROXIMATE",
                "viewport": {
                    "northeast": {
                        "lat": 31.6688967,
                        "lng": 122.1137989
                    },
                    "southwest": {
                        "lat": 30.7798012,
                        "lng": 120.8397067
                    }
                }
            },
            "place_id": "ChIJMzz1sUBwsjURoWTDI5QSlQI",
            "types": [
                "locality",
                "political"
            ]
        },
        {
            "address_components": [
                {
                    "long_name": "上海市",
                    "short_name": "上海市",
                    "types": [
                        "administrative_area_level_1",
                        "political"
                    ]
                },
                {
                    "long_name": "中国",
                    "short_name": "CN",
                    "types": [
                        "country",
                        "political"
                    ]
                }
            ],
            "formatted_address": "中国上海市",
            "geometry": {
                "bounds": {
                    "northeast": {
                        "lat": 31.8727163,
                        "lng": 122.2471487
                    },
                    "southwest": {
                        "lat": 30.6755932,
                        "lng": 120.8568046
                    }
                },
                "location": {
                    "lat": 31.2191829,
                    "lng": 121.4456179
                },
                "location_type": "APPROXIMATE",
                "viewport": {
                    "northeast": {
                        "lat": 31.8727163,
                        "lng": 122.2471487
                    },
                    "southwest": {
                        "lat": 30.6755932,
                        "lng": 120.8568046
                    }
                }
            },
            "place_id": "ChIJBftfxTICsjUR_z-KXanY9fI",
            "types": [
                "administrative_area_level_1",
                "political"
            ]
        },
        {
            "address_components": [
                {
                    "long_name": "中国",
                    "short_name": "CN",
                    "types": [
                        "country",
                        "political"
                    ]
                }
            ],
            "formatted_address": "中国",
            "geometry": {
                "bounds": {
                    "northeast": {
                        "lat": 53.5609739,
                        "lng": 134.7754563
                    },
                    "southwest": {
                        "lat": 17.9996,
                        "lng": 73.4994136
                    }
                },
                "location": {
                    "lat": 35.86166,
                    "lng": 104.195397
                },
                "location_type": "APPROXIMATE",
                "viewport": {
                    "northeast": {
                        "lat": 53.5609739,
                        "lng": 134.7754563
                    },
                    "southwest": {
                        "lat": 17.9996,
                        "lng": 73.4994136
                    }
                }
            },
            "place_id": "ChIJwULG5WSOUDERbzafNHyqHZU",
            "types": [
                "country",
                "political"
            ]
        }
    ],
    "status": "OK"
}

 

转载于:https://www.cnblogs.com/a-du/p/9629853.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值