RxGoogleMaps

Additional

Language
Java
Version
1.1.1 (Sep 29, 2016)
Created
Nov 1, 2015
Updated
Dec 17, 2017
Owner
Sam Doward (sdoward)
Contributors
wviana
Sam Doward (sdoward)
bellol
3
Activity
Badge
Generate
Download
Source code
APK file

Promotion

RxGoogleMaps

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

Ownership

I have been doing a bad job at maintaining this libraries if somebody would like to take ownership of if please contact me sam.doward@gmail.com

Download

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'

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.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.

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) 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.