구글 맵 API를 이용하기위해, 아나콘다 프롬프트 실행하고, 다음을 실행. pip install googlemaps
구글 클라우드의 MAPS API 페이지로 이동하여, API 키를 생성합니다.
https://cloud.google.com/maps-platform/?hl=ko
Google Maps Platform - Location and Mapping Solutions
Create real world and real time experiences for your customers with dynamic maps, routes & places APIs from Google Maps Platform’s location solutions.
mapsplatform.google.com
콘솔로 이동 => Geocoding API 선택 => 사용자 인증정보에서 API 키 생성
구글 맵스를 사용해서 경찰서의 위치(위도, 경도) 정보를 받아온다
import googlemaps
gmaps_key = "API key 입력" # 자신의 key를 사용합니다.
gmaps = googlemaps.Client(key=gmaps_key)
# API 호출 (API CALL)
gmaps.geocode('서울중부경찰서', language='ko')
[{'address_components': [{'long_name': '27',
'short_name': '27',
'types': ['premise']},
{'long_name': '수표로',
'short_name': '수표로',
'types': ['political', 'sublocality', 'sublocality_level_4']},
{'long_name': '중구',
'short_name': '중구',
'types': ['political', 'sublocality', 'sublocality_level_1']},
{'long_name': '서울특별시',
'short_name': '서울특별시',
'types': ['administrative_area_level_1', 'political']},
{'long_name': '대한민국',
'short_name': 'KR',
'types': ['country', 'political']},
{'long_name': '100-032',
'short_name': '100-032',
'types': ['postal_code']}],
'formatted_address': '대한민국 서울특별시 중구 수표로 27',
'geometry': {'location': {'lat': 37.56361709999999, 'lng': 126.9896517},
'location_type': 'ROOFTOP',
'viewport': {'northeast': {'lat': 37.5649660802915,
'lng': 126.9910006802915},
'southwest': {'lat': 37.5622681197085, 'lng': 126.9883027197085}}},
'partial_match': True,
'place_id': 'ChIJc-9q5uSifDURLhQmr5wkXmc',
'plus_code': {'compound_code': 'HX7Q+CV 대한민국 서울특별시',
'global_code': '8Q98HX7Q+CV'},
'types': ['establishment', 'point_of_interest', 'police']}]