با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
RxJava یک کتابخانه برنامه نویسی واکنشی برای نوشتن برنامه های ناهمزمان و مبتنی بر رویداد با استفاده از توالی های قابل مشاهده است.
کتابخانه Maps Rx به شما امکان میدهد توالیهای قابل مشاهده را برای رویدادهای ناهمزمان در Maps SDK برای Android و Places SDK برای Android دریافت کنید تا بتوانید از مجموعه غنی ویژگیهای RxJava استفاده کنید.
نصب و راه اندازی
برای نصب کتابخانه Maps Rx در پروژه Google Maps:
وابستگی های زیر را به فایل build.gradle سطح ماژول خود اضافه کنید:
dependencies {// RxJava bindings for the Maps SDKimplementation("com.google.maps.android:maps-rx:1.0.0")// RxJava bindings for the Places SDKimplementation("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.2.0")implementation("com.google.android.libraries.places:places:4.3.1")implementation("io.reactivex.rxjava3:rxjava:3.1.8")
برای همگام سازی این تغییرات، پروژه خود را در Android Studio بازسازی کنید.
مثال استفاده
یک Observable برای رویدادهای کلیک نشانگر به عنوان یک تابع افزونه در شی GoogleMap دریافت کنید:
googleMap.markerClickEvents().subscribe { marker ->
Log.d("MapsRx", "Marker ${marker.title} was clicked")}
مثال بعدی به شما نشان می دهد که چگونه می توانید از عملگر RxJava، merge ، برای ترکیب رویدادهای مختلف دوربین در یک جریان قابل مشاهده استفاده کنید:
Observable.merge(googleMap.cameraIdleEvents(),googleMap.cameraMoveEvents(),googleMap.cameraMoveCanceledEvents(),googleMap.cameraMoveStartedEvents()).subscribe {// Notified when any camera event occurs}
تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","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"]],["تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی."],[[["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"]]