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 9.6.0
compile 'com.sdoward:rxgooglemaps:1.1.1@aar'
compile 'io.reactivex:rxjava:1.2.0'
compile 'com.google.android.gms:play-services-maps:9.6.0'
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.getMapClickObservable()
.subscribe(new Action1<LatLng>() {
@Override
public void call(LatLng latLng) {
Log.d(MapsActivity.class.getName(), "map click");
}
});
mapObservableProvider.getCameraChangeObservable()
.subscribe(new Action1<CameraPosition>() {
@Override
public void call(CameraPosition cameraPosition) {
Log.d(MapsActivity.class.getName(), "camera position changed");
}
});
You can find a more comprehensive example in the Example
module.
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
To use the example add MAP_API_KEY
as an environment variable
Copyright (C) 2015 Sam Doward
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.