GoogleStaticMapsKit 提供了一个完整且轻量级的 Swift API,用于处理 Google Static Maps API。
![]() 缩放:.world (世界) |
![]() 缩放:.continent (洲) |
![]() 缩放:.city (城市) |
![]() 缩放:.street (街道) |
![]() 缩放:.building (建筑物) |
![]() 样式:[Retro] (复古) |
![]() 样式:[Assassin's Creed IV] (刺客信条 IV) |
![]() 样式:[Lost in the desert] (迷失在沙漠中) |
![]() 样式:[WY] |
// Setting up the API Key (probably in AppDelegate)
GoogleStaticMaps.setAPIKey(apiKey: "your_api_key")
let parameters = Parameters(size: ImageSize(width: 600, height: 400))
let location = Location(center: .geo(latitude: 45.7772, longitude: 3.0870), zoom: .city)
let gsm = GoogleStaticMaps(location: location, parameters: parameters)
let url = gsm.toURL
print("Result : \(url)")
GoogleStaticMapKit 被设计为支持像 SnazzyMaps 这样的 JSON 样式
[...]
let path = jsonFilePath
let styles = StylesImporter.fromJson(path: path).styles
let feature = Feature(styles: styles)
let gsm = GoogleStaticMaps(location: location, parameters: parameters, feature: feature)
有关 Google Maps 样式的更多信息,您可以查看官方 Google 文档
GoogleStaticMapsKit 可通过 CocoaPods 获得。 要安装它,只需将以下行添加到您的 Podfile
use_frameworks!
pod "GoogleStaticMapsKit"
github 'PoissonBallon/GoogleStaticMapsKit'
let package = Package(
name: "MyPackage",
dependencies: [
.Package(url: "https://github.com/PoissonBallon/GoogleStaticMapsKit", majorVersion: 1),
]
)
GoogleStaticMapsKit 在 MIT 许可证下可用。 有关更多信息,请参见 LICENSE 文件。