使用Google maps得到经度和纬度

import requests

response = requests.get('https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA')

resp_json_payload = response.json()

print(resp_json_payload['results'][0]['geometry']['location'])

这时就可以得到结果了。
其中resp_json_payload的结果类似如下:

{
    'results': [
        {
            'address_components': [
                {
                    'long_name': '313',
                    'short_name': '313',
                    'types': [
                        'street_number'
                    ]
                },
                {
                    'long_name': 'DakotaDrive',
                    'short_name': 'DakotaDr',
                    'types': [
                        'route'
                    ]
                },
                {
                    'long_name': 'Murphy',
                    'short_name': 'Murphy',
                    'types': [
                        'locality',
                        'political'
                    ]
                },
                {
                    'long_name': 'CollinCounty',
                    'short_name': 'CollinCounty',
                    'types': [
                        'administrative_area_level_2',
                        'political'
                    ]
                },
                {
                    'long_name': 'Texas',
                    'short_name': 'TX',
                    'types': [
                        'administrative_area_level_1',
                        'political'
                    ]
                },
                {
                    'long_name': 'UnitedStates',
                    'short_name': 'US',
                    'types': [
                        'country',
                        'political'
                    ]
                },
                {
                    'long_name': '75094',
                    'short_name': '75094',
                    'types': [
                        'postal_code'
                    ]
                },
                {
                    'long_name': '4140',
                    'short_name': '4140',
                    'types': [
                        'postal_code_suffix'
                    ]
                }
            ],
            'formatted_address': '313DakotaDr,
            Murphy,
            TX75094,
            USA',
            'geometry': {
                'location': {
                    'lat': 33.0293694,
                    'lng': -96.6194958
                },
                'location_type': 'RANGE_INTERPOLATED',
                'viewport': {
                    'northeast': {
                        'lat': 33.0307183802915,
                        'lng': -96.61814681970849
                    },
                    'southwest': {
                        'lat': 33.0280204197085,
                        'lng': -96.62084478029149
                    }
                }
            },
            'partial_match': True,
            'place_id': 'EiQzMTMgRGFrb3RhIERyLCBNdXJwaHksIFRYIDc1MDk0LCBVU0E',
            'types': [
                'street_address'
            ]
        }
    ],
    'status': 'OK'
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,693评论 19 139
  • 转发自:http://shanshanpt.github.io/2016/05/03/go-gin.html gi...
    dncmn阅读 11,258评论 0 1
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 175,776评论 25 709
  • 有形的事物真实而笨拙,无形的事物奇巧却脆弱。我不善于区分,它们本身的动作和形态,像是和我在开玩笑,但事实上,它们并...
    投稿指南阅读 1,391评论 0 1
  • 今天值班作为守台班,因为机关检查不能玩手机,这可是给我一个很好的放松大脑的机会。我们的日常生活被各种繁琐事情切割...
    风中残留的味道阅读 8,669评论 0 1