zoukankan      html  css  js  c++  java
  • 根据经纬度根据谷歌地图接口获取到当前地址

    /*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"
    }
  • 相关阅读:
    JSTL之迭代标签库
    java中的IO流
    浅谈代理模式
    TreeSet集合
    网络编程之UDP协议
    Java中的多线程
    Java中的面向对象
    JavaScript 函数表达式
    JavaScript 数据属性和访问器属性
    JavaScript 正则表达式语法
  • 原文地址:https://www.cnblogs.com/a-du/p/9629853.html
Copyright © 2011-2022 走看看