Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
RxJava ist eine reaktive Programmierbibliothek zum Erstellen asynchroner und ereignisbasierter Programme mithilfe von beobachtbaren Sequenzen.
Mit der Maps Rx-Bibliothek erhalten Sie beobachtbare Sequenzen für asynchrone Ereignisse im Maps SDK for Android und Places SDK for Android. So profitieren Sie von allen RxJava-Funktionen.
Installation
So installieren Sie die Maps Rx-Bibliothek in Ihrem Google Maps-Projekt:
Fügen Sie der Datei build.gradle auf Modulebene die folgenden Abhängigkeiten hinzu:
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'
Erstellen Sie Ihr Projekt in Android Studio neu, um die Änderungen zu synchronisieren.
Verwendungsbeispiel
Beobachtbare Sequenz für Markierungs-Klickereignisse als Erweiterungsfunktion für das GoogleMap-Objekt erhalten:
Im nächsten Beispiel wird gezeigt, wie Sie mit dem RxJava-Operator merge verschiedene Kameraereignisse in einem gemeinsamen Stream für beobachtbare Sequenzen zusammenführen können:
Observable.merge(
googleMap.cameraIdleEvents(),
googleMap.cameraMoveEvents(),
googleMap.cameraMoveCanceledEvents(),
googleMap.cameraMoveStartedEvents()
).subscribe {
// Notified when any camera event occurs
}
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Benötigte Informationen nicht gefunden","missingTheInformationINeed","thumb-down"],["Zu umständlich/zu viele Schritte","tooComplicatedTooManySteps","thumb-down"],["Nicht mehr aktuell","outOfDate","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Problem mit Beispielen/Code","samplesCodeIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 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"]]