All Projects → 99Taxis → Rxplaces

99Taxis / Rxplaces

Licence: other
A Google Maps Webservice API made simple.

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Rxplaces

rxjava2-http
Transmit RxJava2 Flowable over http with non-blocking backpressure
Stars: ✭ 19 (-66.07%)
Mutual labels:  reactive, rxjava
Rxgps
Finding current location cannot be easier on Android !
Stars: ✭ 307 (+448.21%)
Mutual labels:  rxjava, reactive
RxJava-Codelab
Codelab project for demonstration of RxJava features
Stars: ✭ 44 (-21.43%)
Mutual labels:  reactive, rxjava
Rxjava2 Extras
Utilities for use with RxJava 2
Stars: ✭ 167 (+198.21%)
Mutual labels:  rxjava, reactive
Rxjavafiberinterop
Library for interoperation between RxJava 3 and Project Loom's Fibers.
Stars: ✭ 19 (-66.07%)
Mutual labels:  rxjava, reactive
Rxjava Spring Boot Starter
RxJava Spring MVC integration
Stars: ✭ 180 (+221.43%)
Mutual labels:  rxjava, reactive
Rxkprefs
🛠 A small Kotlin library to make shared preferences easy + RxJava and Coroutines support
Stars: ✭ 264 (+371.43%)
Mutual labels:  rxjava, reactive
Rxbus
Android reactive event bus that simplifies communication between Presenters, Activities, Fragments, Threads, Services, etc.
Stars: ✭ 79 (+41.07%)
Mutual labels:  rxjava, reactive
Rxfirebase
Rxjava 2.0 wrapper on Google's Android Firebase library.
Stars: ✭ 509 (+808.93%)
Mutual labels:  rxjava, reactive
Vertx Guide For Java Devs
Vert.x 3 guide for Java developers
Stars: ✭ 500 (+792.86%)
Mutual labels:  rxjava, reactive
Rsocket Java
Java implementation of RSocket
Stars: ✭ 2,099 (+3648.21%)
Mutual labels:  rxjava, reactive
Rxjava2 Operators Magician
你用不惯 RxJava,只因缺了这把钥匙 🔑 You are not used to RxJava, just because of the lack of this key.
Stars: ✭ 868 (+1450%)
Mutual labels:  rxjava, reactive
Knotx
Knot.x is a highly-efficient and scalable integration framework designed to build backend APIs
Stars: ✭ 119 (+112.5%)
Mutual labels:  rxjava, reactive
Javawebsocketclient
RxJava WebSocket library for Java and Android
Stars: ✭ 188 (+235.71%)
Mutual labels:  rxjava, reactive
Vertx Mqtt
Vert.x MQTT
Stars: ✭ 117 (+108.93%)
Mutual labels:  rxjava, reactive
Binder
An Annotation processor that allows binding two classes with each other, where the first class can listen to the updates of the second class ... ideal for MVVM and similar patterns
Stars: ✭ 21 (-62.5%)
Mutual labels:  reactive, rxjava
Android Okgraphql
Reactive GraphQl client for Android
Stars: ✭ 64 (+14.29%)
Mutual labels:  rxjava, reactive
Rxjava2 Jdbc
RxJava2 integration with JDBC including Non-blocking Connection Pools
Stars: ✭ 360 (+542.86%)
Mutual labels:  rxjava, reactive
Rxreactor
A Kotlin framework for a reactive and unidirectional RxJava application architecture
Stars: ✭ 19 (-66.07%)
Mutual labels:  rxjava, reactive
Rxjava Android Samples
Learning RxJava for Android by example
Stars: ✭ 7,520 (+13328.57%)
Mutual labels:  rxjava, reactive

RxPlaces Build Status Download

A reactive approach for the Google Maps Webservice API

Current features:

  • Places Autocomplete
  • Reverse Geocoding from given place_id

Download

compile 'com.a99.rxplaces:library:0.1.0-alpha3'

Proguard Rules

Add the following line to your proguard-rules.pro

-keep class com.a99.rxplaces.** { *; }

Places Autocomplete

Initialization

You should use the function create(GOOGLE_MAPS_API_AUTOCOMPLETE_KEY), where GOOGLE_MAPS_API_AUTOCOMPLETE_KEY is the generated key from the Google developer console:

val rxAutocomplete = RxAutocomplete.create(GOOGLE_MAPS_API_AUTOCOMPLETE_KEY)

Usage

You can observe an EditText:

rxAutocomplete.observe(editText, options)

You can also observe any String data source:

Observable<String> dataSource = Observable.just("place");

rxAutocomplete.observe(dataSource, options)

Options Parameters

You can customize any value provided from the Google Maps Place Autocomplete webservice:

val options = AutocompleteOptions.create {
  offset { MIN_OFFSET }
  location { latLng.latitude to latLng.longitude }
  radius { RADIUS_IN_METERS }
  language { locale.language }
  types { AutocompleteType.CITIES } //Check the AutocompleteType class to get all the possible types
  components { listOf(DEFAULT_COUNTRY) }
  strictBounds { true }
}

Listening events

You can use the stateStream() to handle the provided events from the API:

rxAutocomplete.stateStream()
    .observeOn(AndroidSchedulers.mainThread())
    .subscribe {
      when(it) {
        AutocompleteState.QUERYING -> view.showProgress()
        AutocompleteState.FAILURE -> view.showError()
        AutocompleteState.SUCCESS -> view.hideProgress()
      }
    }

API Defaults

  • The default min key stroke is 3
  • The default query interval is 2 seconds

Reverse Geocoding

To get the latitude and longitude from a given place, you can use the GeocodeRepository

Initialization

You should use the function create(GOOGLE_MAPS_API_GEOCODE_KEY), where GOOGLE_MAPS_API_GEOCODE_KEY is the generated key from the Google developer console:

val geocodeRepository = GeocodeRepository.create(BuildConfig.GOOGLE_MAPS_API_GEOCODE_KEY)

Usage

You can use the method reverseGeocode(placeId):

geocodeRepository.reverseGeocode(placeId)
    .subscribeOn(Schedulers.io())
    .take(1)
    .observeOn(AndroidSchedulers.mainThread())
    .subscribe(
        { view.dispatchGeocodeResult(it)},
        { view.showError() }
    )

Accessing the provided results

You can easily get the result information through the API given functions, example:

private fun createResult(result: GeocodeResult) = Result(
  latitude = result.geometry.location.lat,
  longitude = result.geometry.location.lng,
  formattedAddress = result.formattedAddress,
  street = result.getStreetName(),
  number = result.getStreetNumber(),
  city = result.getCity(),
  neighborhood = result.getNeighborhood(),
  postalCode = result.getPostalCode(),
)

Note: the API will return the long name attribute from the response.

Demo

Look the demo folder

Tests

./gradlew test

Contributing

Don't be shy, send a Pull Request! Here is how:

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -m 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

Copyright (C) 2017 99

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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].