首页 > 其他 > 详细

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

时间:2018-09-11 20:57:44      阅读:286      评论:0      收藏:0      [点我收藏+]

/*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)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!