카테고리 없음

[React Native] 날씨 API, 역지오코딩(위도/경도 > 주소), 미세먼지 API

안다희 2020. 4. 29. 03:23
728x90

1. 날씨 API

https://home.openweathermap.org/api_keys

 

Members

Enter your email address and we will send you a link to reset your password.

home.openweathermap.org

api key 확인하고~

 

위도 경도 필요해

https://coding-dahee.tistory.com/171

 

[React Native] 현재 위치 위도/경도 알기

- 라이브러리 https://github.com/react-native-community/react-native-geolocation react-native-community/react-native-geolocation Geolocation APIs for React Native. Contribute to react-native-communit..

coding-dahee.tistory.com

 

 

https://openweathermap.org/current

 

Current weather data - OpenWeatherMap

Access current weather data for any location on Earth including over 200,000 cities! Current weather is frequently updated based on global models and data from more than 40,000 weather stations. Data is available in JSON, XML, or HTML format. We provide 40

openweathermap.org

By geographic coordinates

 

 

- 위도 경도로 도시 이름도 알아내기 1

https://choiyb2.tistory.com/77

 

[JAVA] GPS의 위도 경도를 한글 주소명으로 변환(geocoding, JSON)

GPS의 위도 경도를 한글 주소명으로 바꾸려면 먼저 구글의 힘을 빌려야 한다 주소를 GPS의 위도 경도로 바꾸르면 구글 지오 코딩이지만 GPS의 위도 경도를 한글 주소로 바꾸기 위해서는 구글 역 지오 코딩을 사용..

choiyb2.tistory.com

https://developers.google.com/maps/documentation/geocoding/start?hl=ko#ReverseGeocoding

 

Get Started  |  Geocoding API  |  Google Developers

Geocoding converts addresses into geographic coordinates to be placed on a map. Reverse Geocoding finds an address based on geographic coordinates or place IDs.

developers.google.com

 

1) google cloud platform 홈페이지 고고

2) Geocoding API 검색 후 추가

3) 결제 계정 연결

4) 사용자 인증 정보에서 

Browser key (auto created by Firebase)

이용

      const response = await fetch(
        `https://maps.googleapis.com/maps/api/geocode/json?latlng=37.5399286,127.0684114&language=ko&key=${GOOGLE_CLOUD_BROWSER_API_KEY}`,
      );
      const responseJson: GeocodingResponse = await response.json();
      const addressArr: string[] = responseJson.results[0].formatted_address.split(
        ' ',
      );
      setCityName(`${addressArr[2]} ${addressArr[3]}`);

cityName: "광진구 자양4동"

 

- 위도 경도로 도시 이름도 알아내기 2

www.bigdatacloud.com/supported-languages

 

Supported languages for locality names

BigDataCloud API offers locality names to be retrieved in a language of choice. Most of the two-character language codes as defined by ISO 639-1 standard can serve as a localityLanguage parameter to identify the language required. The table below is li

www.bigdatacloud.com

GCP와 달리 무료!

GCP 쓰다가 크레딧을 다 써서 찾아본 무료 API.

팁) 각 나라에 맞는 locale code는 react-native-localize 라이브러리를 이용하면 된다!

    import Geolocation, {
      GeolocationError,
    } from '@react-native-community/geolocation';
    import * as RNLocalize from "react-native-localize";

	const locale = RNLocalize.getLocales();

    const getCityName = (): Promise<string> => {
      return new Promise((resolve, reject) => {
        Geolocation.getCurrentPosition(
          async ({ coords }: CurrentPosition) => {
            const lat = coords.latitude;
            const lon = coords.longitude;

            const response = await fetch(
              `https://api.bigdatacloud.net/data/reverse-geocode-client?latitude=${lat}&longitude=${lon}&localityLanguage=${locale}`,
            );
            const responseJson: GeocodingResponse = await response.json();
            console.log('🔫 1 response', response);
            console.log('🔫 2 responseJson', responseJson);

            resolve(responseJson.city);
          },
          async (error: GeolocationError) => {},
          {
            enableHighAccuracy: false,
            timeout: 2000,
            maximumAge: 3600000,
          },
        );
      });
    };

 

 

2. 미세먼지 API

https://www.data.go.kr/iim/api/selectAPIAcountView.do

 

공공데이터 포털

국가에서 보유하고 있는 다양한 데이터를『공공데이터의 제공 및 이용 활성화에 관한 법률(제11956호)』에 따라 개방하여 국민들이 보다 쉽고 용이하게 공유•활용할 수 있도록 공공데이터(Dataset)와 Open API로 제공하는 사이트입니다.

www.data.go.kr

API KEY 발급받고 1시간 뒤에 사용 가능.

예제 문서 그대로 따라해보기 (아직 1시간 안지나서 못함)

 

https://www.data.go.kr/tcs/dss/selectApiDataDetailView.do?publicDataPk=15000581

 

공공데이터 포털

국가에서 보유하고 있는 다양한 데이터를『공공데이터의 제공 및 이용 활성화에 관한 법률(제11956호)』에 따라 개방하여 국민들이 보다 쉽고 용이하게 공유•활용할 수 있도록 공공데이터(Dataset)와 Open API로 제공하는 사이트입니다.

www.data.go.kr

오류 나서 여기에 문의 해둠

 

 

 

 

 

 

Buy Me A Coffee!

https://www.buymeacoffee.com/daheeahn

 

daheeahn is app developer

Hey 👋 I just created a page here. You can now buy me a coffee!

www.buymeacoffee.com