Giter Club home page Giter Club logo

rxgooglemaps's Introduction

RxGoogleMaps

CircleCI Swift Version License Platform

RxGoogleMaps is a RxSwift wrapper for GoogleMaps.

Example Usages

Setup GoogleMaps

// Setup API Key
GMSServices.provideAPIKey("Your-API-Key")
// Setup GMSMapview from Interface Builder
@IBOutlet weak var mapView: GMSMapView!

or

// Setup GMSMapview
let mapView = GMSMapView(frame: self.view.bounds)
self.view.addSubview(mapView)

Observing properties

// Camera position

mapView.rx.didChange.asDriver()
    .drive(onNext: { print("Did change position: \($0)") })
    .disposed(by: disposeBag)

// Marker tapped

mapView.rx.didTapAt.asDriver()
    .drive(onNext: { print("Did tap at coordinate: \($0)") })
    .disposed(by: disposeBag)

// Location update

mapView.rx.myLocation
    .subscribe(onNext: { location in
        if let l = location {
            print("My location: (\(l.coordinate.latitude), \(l.coordinate.longitude))")
        } else {
            print("My location: nil")
        }
    })
    .disposed(by: disposeBag)

Binding properties

// Properties

button.rx.tap
    .map { false }
    .bind(to: mapView.rx.trafficEnabled.asObserver())
    .disposed(by: disposeBag)

// Camera animations

button.rx.tap
    .map { 14 }
    .bind(to: mapView.rx.zoomToAnimate)
    .disposed(by: disposeBag)

button.rx.tap
    .map { GMSCameraPosition.camera(withLatitude: latitude, longitude: longitude, zoom: 8, bearing: 10, viewingAngle: 30) }
    .bind(to: mapView.rx.cameraToAnimate)
    .disposed(by: disposeBag)

// Selected marker

button.rx.tap
    .map { myMarker }
    .bind(to: mapView.rx.selectedMarker.asObserver())
    .disposed(by: disposeBag)

// GMSMarker or GMSOverlay properties

button.rx.tap
    .map{ 180.0 }
    .bind(to: marker.rx.rotation.asObserver())
    .disposed(by: disposeBag)

button.rx.tap
    .map{ UIColor.red }
    .bind(to: circle.rx.fillColor.asObserver())
    .disposed(by: disposeBag)

Delegates which have a return value

// func mapView(_ mapView: GMSMapView, didTap marker: GMSMarker) -> Bool

mapView.rx.handleTapMarker { false }

// func mapView(_ mapView: GMSMapView, markerInfoWindow marker: GMSMarker) -> UIView?

mapView.rx.handleMarkerInfoWindow { marker in
    let label = UILabel(frame: CGRect(x: 0, y: 0, width: 180, height: 60))
    label.textAlignment = .center
    label.textColor = UIColor.brown
    label.font = UIFont.boldSystemFont(ofSize: 16)
    label.backgroundColor = UIColor.yellow
    label.text = marker.title
    return label
}

Note: More examples can be found at the example project from this repo!.

Installation

Swift Package Manager

Add as a dependecy to your Swift Package

dependencies: [
  .package(url: "https://github.com/RxSwiftCommunity/RxGoogleMaps.git", branch: "master")
]

CocoaPods

Note: Due to the fact Google Maps is delivered as a static library, you must have CocoaPods 1.4.0 installed to install this library.

  • Add to your Podfile:
pod 'RxGoogleMaps'

Than run pod install, and you should be good to go!

Example Project

  1. Get your own API Key a key at https://developers.google.com/maps/documentation/ios-sdk/
  2. Open the example project and set your API Key in AppDelegate

Requirements

License

MIT

rxgooglemaps's People

Contributors

aksswami avatar freak4pc avatar gabrielaraujo avatar inkyfox avatar k-yamada avatar kchykt avatar leoru avatar mashe avatar montazher avatar rwjc avatar valeriyvan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rxgooglemaps's Issues

Cluster

HI guys,

Thanks for your Framework,
I have a small question. How to use it with Clustering that is in Google-Maps-iOS-Utils?
Because clustering provide something like that:

 clusterManager.setDelegate(self, mapDelegate: self)

and this "destroyed" connection with RxGoogleMaps.

Thanks.

What are these XXXWrapper thingys?

I see that a lot of these ControlEvents have a XXXWrapper counterpart. For example, idleAtPosition and idleAtPositionWrapper. How can I make use of the XXXWrappers?

Carthage support doesn't work

Is installation of this project via Carthage expected to work? It seems like it is/was supported since there is a Cartfile in the repo, but without installing the Pods, Carthage cannot build the project.

Build of RxGoogleMap-iOS target fails

Build of RxGoogleMap-iOS target fails with linker error:
ld: framework not found RxSwift

carthage build --no-skip-current fails with same error
ld: framework not found RxSwift
clang: error: linker command failed with exit code 1 (use -v to see invocation)

RX way to add marker? (Question)

Is there a way to use ViewModel's Driver to drive MapView's markers?

In an example, it shows how to use set up one by one marker manually. But what if I get markers from a server?

Thank you!

Carthage error (question)

Hey can u help me please :)
carthage update RxGoogleMaps
Skipped building RxGoogleMaps due to the error: Dependency "RxGoogleMaps" has no shared framework schemes
tell me what I'm doing wrong ;(
i try add to cartfile
github "RxSwiftCommunity/RxGoogleMaps" "master"
github "RxSwiftCommunity/RxGoogleMaps" ~> 2.2.0

Not able to install version 3.1.0 via Cocoapods

Podfile :-

pod 'RxGoogleMaps', '~> 3.1.0'

Output :-

Analyzing dependencies
[!] CocoaPods could not find compatible versions for pod "RxGoogleMaps":
  In Podfile:
    RxGoogleMaps (~> 3.1.0)

None of your spec sources contain a spec satisfying the dependency: `RxGoogleMaps (~> 3.1.0)`.

You have either:
 * mistyped the name or version.
 * not added the source repo that hosts the Podspec to your Podfile.

Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by default.

Cocoapods version:- 1.5.3, Xcode 10, Swift 4.2

Unable to build using Cocoapods

Hi there,

I'm unable to build the project, with the error reported 'No such module RxSwift'

Any ideas what could be wrong?

My Podfile looks something like this...

platform :ios, '9.0'
use_frameworks!

...

  pod 'RxSwift'
  pod 'RxCocoa'
  pod 'GoogleMaps'
  pod 'RxGoogleMaps', :git => 'https://github.com/RxSwiftCommunity/RxGoogleMaps', :commit => 'b182d08'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.