StaticMapRequestBuilder
一个轻量级的辅助工具,用于创建具有类型安全的 Google Maps 静态 API 的 URL。
安装
StaticMapRequestBuilder 可通过 CocoaPods 获得。要安装它,只需将以下行添加到您的 Podfile
pod 'StaticMapRequestBuilder'
使用
快速入门
let mapSize = CGSize(width: 300, height: 200)
let coord = CLLocationCoordinate2D(latitude: 40.7484, longitude: -73.9857)
let marker = Marker(coordinate: coord, color: .blue)
let mapRequestUrl = MapRequestBuilder(withSize: mapSize)
.addCenter(.address("Midtown Manhattan, New York, NY"))
.addMarker(marker)
.addZoom(13)
.imageFormat(.png)
.mapType(.roadmap)
.retinaScale()
.build()
//Load image from mapRequestUrl
if let url = mapRequestUrl {
imageView.kf.setImage(with: url)
}
许可证
StaticMapRequestBuilder 授权于 MIT 许可证。有关更多信息,请参阅 LICENSE 文件。