PlacesPicker 0.0.3

PlacesPicker 0.0.3

Piotr Bernad维护。



 
依赖项
GoogleMaps~> 3.1.0
GooglePlaces~> 3.1.0
 

  • Piotr Bernad

Google Places Picker

高度可自定义的地点选择器,基于Google Places API和Google Geocode服务。

选择器允许用户直接在地图上选择位置或使用带自动完成的搜索。因此,它提供GMSPlace对象。

安装

todo

用法

要使用Picker,您需要提供Google Places API密钥和Google Maps密钥。为此,您应该调用

PlacePicker.configure(googleMapsAPIKey: "YOUR_KEY", placesAPIKey: "YOUR_PLACES_KEY")

每次您想显示控制器时,调用

let controller = PlacePicker.placePickerController()
controller.delegate = self
let navigationController = UINavigationController(rootViewController: controller)
self.show(navigationController, sender: nil)

所有事件都通过PlacesPickerDelegate传递。

可选地,您还可以传递PlacePickerConfig,这样就可以自定义选择器的外观和行为。

自定义

您可以通过实现自己的Renderer协议类轻松自定义地图和列表的外观。

要自定义列表外观,请在初始化配置时实现并发送渲染器对象。

public protocol PlacesListRenderer {
    func registerCells(tableView: UITableView)
    func cellForRowAt(indexPath: IndexPath, tableView: UITableView, object: PlacesListObjectType) -> UITableViewCell
}

要自定义 MapView 的外观,请实现。

public protocol PickerRenderer {
    func configureCancelButton(barButtonItem: UIBarButtonItem)
    func configureSearchButton(barButtonItem: UIBarButtonItem)
    func configureMapView(mapView: GMSMapView)
    func configureTableView(mapView: UITableView)
}

贡献

欢迎贡献。

待办事项

  1. 设置 CocoaPods
  2. 设置 Carthage
  3. 编写测试