Update geo documentation

This commit is contained in:
Daniel Saidi 2021-09-08 11:59:19 +02:00
parent 46de9ae0d4
commit 9a1c070e3e
4 changed files with 26 additions and 0 deletions

View File

@ -12,11 +12,17 @@ public class AppleMapsService: ExternalMapService {
public init() {} public init() {}
/**
Get the external url of a certain coordinate.
*/
public func getUrl(for coordinate: CLLocationCoordinate2D) -> URL? { public func getUrl(for coordinate: CLLocationCoordinate2D) -> URL? {
let string = "http://maps.apple.com/maps?ll=\(coordinate.latitude),\(coordinate.longitude)" let string = "http://maps.apple.com/maps?ll=\(coordinate.latitude),\(coordinate.longitude)"
return URL(string: string) return URL(string: string)
} }
/**
Get the external url of a certain navigation.
*/
public func getUrl(from: CLLocationCoordinate2D, to: CLLocationCoordinate2D) -> URL? { public func getUrl(from: CLLocationCoordinate2D, to: CLLocationCoordinate2D) -> URL? {
let string = "http://maps.apple.com/maps?saddr=\(from.latitude),\(from.longitude)&daddr=\(to.latitude),\(to.longitude)" let string = "http://maps.apple.com/maps?saddr=\(from.latitude),\(from.longitude)&daddr=\(to.latitude),\(to.longitude)"
return URL(string: string) return URL(string: string)

View File

@ -15,6 +15,13 @@ import CoreLocation
*/ */
public protocol ExternalMapService { public protocol ExternalMapService {
/**
Get the external url of a certain coordinate.
*/
func getUrl(for coordinate: CLLocationCoordinate2D) -> URL? func getUrl(for coordinate: CLLocationCoordinate2D) -> URL?
/**
Get the external url of a certain navigation.
*/
func getUrl(from: CLLocationCoordinate2D, to: CLLocationCoordinate2D) -> URL? func getUrl(from: CLLocationCoordinate2D, to: CLLocationCoordinate2D) -> URL?
} }

View File

@ -12,11 +12,17 @@ public class GoogleMapsService: ExternalMapService {
public init() {} public init() {}
/**
Get the external url of a certain coordinate.
*/
public func getUrl(for coordinate: CLLocationCoordinate2D) -> URL? { public func getUrl(for coordinate: CLLocationCoordinate2D) -> URL? {
let string = "comgooglemaps://?center=\(coordinate.latitude),\(coordinate.longitude)" let string = "comgooglemaps://?center=\(coordinate.latitude),\(coordinate.longitude)"
return URL(string: string) return URL(string: string)
} }
/**
Get the external url of a certain navigation.
*/
public func getUrl(from: CLLocationCoordinate2D, to: CLLocationCoordinate2D) -> URL? { public func getUrl(from: CLLocationCoordinate2D, to: CLLocationCoordinate2D) -> URL? {
let string = "comgooglemaps://?saddr=\(from.latitude),\(from.longitude)&daddr=\(to.latitude),\(to.longitude)" let string = "comgooglemaps://?saddr=\(from.latitude),\(from.longitude)&daddr=\(to.latitude),\(to.longitude)"
return URL(string: string) return URL(string: string)

View File

@ -20,7 +20,14 @@ public struct WorldCoordinate: Identifiable, Hashable {
public var id: String { name } public var id: String { name }
/**
The name of the coordinate.
*/
public let name: String public let name: String
/**
The coordinate value.
*/
public let coordinate: CLLocationCoordinate2D public let coordinate: CLLocationCoordinate2D
public static func == (lhs: WorldCoordinate, rhs: WorldCoordinate) -> Bool { public static func == (lhs: WorldCoordinate, rhs: WorldCoordinate) -> Bool {