계기
- 뭔가 아이디어를 찾던 도중 누군가로부터 이런 아이디어를 받았다.
- “코로나시기에도 영업늦게까지하는 가게검색 어떤가요 틈새시장으로다가”
- 실용적인가 하는 논란은 둘째 치고, 토이프로젝트로 나쁘지 않다고 판단
조사
구현은 어떻게 하지?
- Native App + API ?
- Java? / Kotlin?
- Native App + API ?
늦게까지 하는 가게는 어떻게 검색하지?
- 구글 API? / 네이버 지도 API? / 카카오 지도 API?
- 우선 구글 지도 API
- 콜.
- 이건 돈이 필요하네?
- 200달러까지는 청구하지 않으니까 괜찮아.
- 우선 구글 지도 API
- 구글 API? / 네이버 지도 API? / 카카오 지도 API?
구글 맵 API 가장 간단하게 사용할 수 있는 방법은 뭐야?
- Powershell로 간단히 할 수 있을까?
- https://geekeefy.wordpress.com/2016/05/17/powershell-module-for-google-map/
- 누군가가 googlemap 모듈을 만들어서 올려놨다.
- 그렇게 자주 업데이트는 되지 않았다. 4년전이 마지막 업데이트.
- 누군가가 googlemap 모듈을 만들어서 올려놨다.
누군가가 이를 이용한 응용 스크립트를 만들어놓았나?
실험
- install-module하려고 했는데 Get-TimeZone 커맨드가 중복되어서 곤란했다.
- Get-TimeZone은 표준 명령어이기 때문에 Install-Module은 포기해야만 했다.
- git clone해서 받아서 그것만 로드해봤다.
https://github.com/PrateekKumarSingh/GoogleMap
- 이 스크립트는 환경변수에서 Key 문자열을 찾는다.
- 우선 구글 API Key 등록해야했다.
- $profile에 넣어두어야겠다.
응용
pode와 연결해봤다.
소스코드
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
Start-PodeServer { Add-PodeEndpoint -Address 0.0.0.0 -Port 8080 -Protocol Http Add-PodeRoute -Method Get -Path '/api/services' -ScriptBlock { Add-PodeHeader -Name 'Access-Control-Allow-Origin' -Value '*' Add-PodeHeader -Name 'Access-Control-Allow-Methods' -Value '*' $global:ProgressPreference = 'SilentlyContinue' $ProgressPreference = 'SilentlyContinue' $coordinates = $WebEvent.Query['coordinates'] $res = $null $statuscode = 200 try { $env:GoogleGeoloc_API_Key = "AIza...." . C:\toy\GoogleMap\Get-NearbyPlace.ps1 $res = $coordinates | Get-NearbyPlace -Radius 1000 -TypeOfPlace "Restaurant" # Write-Debug $res | convertto-json } catch { # Write-Debug "error" $res = @{exception = $_} $statuscode = 400 } Write-PodeJsonResponse -Value @{result = $res} -StatusCode $statuscode } }
파이어월을 열어야 했다.
netsh advfirewall firewall add rule name = "Open port 8080 test" dir=in action=allow
실행
결과
- curl로 문제없이 실행되었다.
Ref
- https://geekeefy.wordpress.com/2016/05/17/powershell-module-for-google-map/
- https://til.secretgeek.net/powershell/Use_Google_Maps.html
- https://github.com/PrateekKumarSingh/GoogleMap
이렇게 썼는데 284단어밖에 안돼?