RxJava는 관측 가능한 시퀀스를 사용하여 비동기 프로그램 및 이벤트 기반 프로그램을 작성하기 위한 반응형 프로그래밍 라이브러리입니다.
지도 Rx 라이브러리를 사용하면 Android용 Maps SDK 및 Android용 Places SDK에서 비동기 이벤트에 대한 관측 가능한 시퀀스를 수신하여 다양한 RxJava 기능을 활용할 수 있습니다.
설치
Google 지도 프로젝트에 지도 Rx 라이브러리를 설치하려면 다음 단계를 따르세요.
모듈 수준 build.gradle 파일에 다음 종속 항목을 추가하세요.
dependencies {
// RxJava bindings for the Maps SDK
implementation 'com.google.maps.android:maps-rx:1.0.0'
// RxJava bindings for the Places SDK
implementation 'com.google.maps.android:places-rx:1.0.0'
// It is recommended to also include the latest Maps SDK, Places SDK and RxJava so you
// have the latest features and bug fixes.
implementation "com.google.android.gms:play-services-maps:19.0.0"
implementation 'com.google.android.libraries.places:places:3.5.0'
implementation 'io.reactivex.rxjava3:rxjava:3.1.8'
Android 스튜디오에서 프로젝트를 재구성하여 변경사항을 동기화하세요.
사용 예
마커 클릭 이벤트에 대한 관측 가능 함수를 GoogleMap 객체의 확장 함수로 수신합니다.
다음 예는 RxJava 연산자 merge를 사용하여 다양한 카메라 이벤트를 관측 가능한 단일 스트림으로 결합하는 방법을 보여줍니다.
Observable.merge(
googleMap.cameraIdleEvents(),
googleMap.cameraMoveEvents(),
googleMap.cameraMoveCanceledEvents(),
googleMap.cameraMoveStartedEvents()
).subscribe {
// Notified when any camera event occurs
}
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2024-08-13(UTC)"],[[["The Maps Rx library enables the use of RxJava with the Maps SDK and Places SDK for Android to handle asynchronous events."],["It provides observable sequences for events like marker clicks and camera movements, allowing developers to leverage RxJava features."],["You can install the library by adding specific dependencies to your `build.gradle` file and rebuilding your project."],["The library offers extension functions and operators to simplify the integration of RxJava with Google Maps functionality."]]],["The Maps Rx library, designed for use with RxJava, allows developers to receive observable sequences for asynchronous events on the Maps SDK and Places SDK for Android. To install, add dependencies for `maps-rx`, `places-rx`, and the latest `Maps SDK`, `Places SDK`, and `RxJava` to the `build.gradle` file, then rebuild the project. Developers can subscribe to events, like marker clicks, using extension functions. The library also supports merging multiple event types, such as various camera events, into a single observable stream using RxJava operators.\n"]]