Skip to content

minaroid/RxGoogleMaps

Repository files navigation

RxGoogleMaps

Download API

Build Status codecov.io

Android Arsenal

A library which provides an RxJava wrapper for google maps. It is something similar to [Jake Whartons rxBindings] (https://github.com/JakeWharton/RxBinding) but for google maps.

This is currently using play services 17.0.0

Download

implementation 'com.github.minageorge5080:RxGoogleMaps:1.1.3'
implementation 'io.reactivex.rxjava2:rxjava:2.0.5'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'

Usage

Instantiate the MapObservableProvider by passing in a MapFragment, MapView or SupportMapFragment

MapFragment mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.map);
mapObservableProvider = new MapObservableProvider(mapFragment);

You then have access to the GoogleMap observbles. They can be used like so

mapObservableProvider.getCameraMoveStartedObservable()
                .subscribe(integer -> Log.d(TAG, "map move started: " + integer),
                        throwable -> Log.e(TAG, throwable.getLocalizedMessage()));
        
mapObservableProvider.getMapLongClickObservable()
                .subscribe(latLng -> Log.d(TAG, "map long click"),
                        throwable -> Log.e(TAG, throwable.getLocalizedMessage()));
                        

You can find a more comprehensive example in the Example module.

API

There is one class to interact with which is MapObservableProvider. This has 3 constructors which accepts either...

  • MapFragment
  • SupportMapFragment
  • MapView

This provides the following observables...

  • MapReady
  • MapClick
  • MapLngClick
  • PolylineClick
  • PolygonClick
  • CircleClick
  • GroundOverlayClick
  • MarkerClick
  • InfoWindowClick
  • InfoWindowLongClick
  • InfoWindowClose
  • DragChange
  • CameraChange
  • CameraIdle
  • CameraMove
  • CameraMoveStarted
  • CameraMoveCanceled
  • IndoorBuildingChange
  • Snapshot

Example Setup

To use the example add MAP_API_KEY as an environment variable

License

Copyright (C) 2019 Mina George

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.