mapkit-geo
4
总安装量
3
周安装量
#53939
全站排名
安装命令
npx skills add https://github.com/makgunay/claude-swift-skills --skill mapkit-geo
Agent 安装分布
opencode
3
claude-code
3
codex
3
cursor
3
gemini-cli
2
github-copilot
2
Skill 文档
MapKit & GeoToolbox
PlaceDescriptor (GeoToolbox)
Standardized place representation that works across mapping services.
import GeoToolbox
import MapKit
// From address
let place = PlaceDescriptor(
representations: [.address("121 James's St\nDublin 8\nIreland")],
commonName: "Obelisk Fountain"
)
// From coordinates
let tower = PlaceDescriptor(
representations: [.coordinate(CLLocationCoordinate2D(latitude: 48.8584, longitude: 2.2945))],
commonName: "Eiffel Tower"
)
// Multiple representations
let statue = PlaceDescriptor(
representations: [
.coordinate(CLLocationCoordinate2D(latitude: 40.6892, longitude: -74.0445)),
.address("Liberty Island, New York, NY 10004")
],
commonName: "Statue of Liberty"
)
// From MKMapItem
let descriptor = PlaceDescriptor(item: mapItem)
// Access properties
let coord = descriptor.coordinate // CLLocationCoordinate2D?
let address = descriptor.address // String?
let name = descriptor.commonName // String?
Third-Party Place IDs (SupportingPlaceRepresentation)
// Attach third-party identifiers
let place = PlaceDescriptor(
representations: [.coordinate(coord)],
supportingRepresentations: [
SupportingPlaceRepresentation(service: .googleMaps, identifier: "ChIJ..."),
SupportingPlaceRepresentation(service: .here, identifier: "here:..."),
SupportingPlaceRepresentation(service: .foursquare, identifier: "4b...")
],
commonName: "My Place"
)
// Extract specific service ID
func getGooglePlaceID(from descriptor: PlaceDescriptor) -> String? {
descriptor.supportingRepresentations
.first(where: { $0.service == .googleMaps })?
.identifier
}
Convert PlaceDescriptor â MKMapItem
func convertToMapItem(descriptor: PlaceDescriptor) async throws -> MKMapItem? {
if let coord = descriptor.coordinate {
let placemark = MKPlacemark(coordinate: coord)
let item = MKMapItem(placemark: placemark)
item.name = descriptor.commonName
return item
}
if let address = descriptor.address {
let geocoder = CLGeocoder()
let placemarks = try await geocoder.geocodeAddressString(address)
if let first = placemarks.first {
return MKMapItem(placemark: MKPlacemark(placemark: first))
}
}
return nil
}
SwiftUI Map
import MapKit
struct MapView: View {
@State private var position: MapCameraPosition = .automatic
let places: [PlaceDescriptor]
var body: some View {
Map(position: $position) {
ForEach(places.indices, id: \.self) { i in
if let coord = places[i].coordinate {
Marker(places[i].commonName ?? "Place", coordinate: coord)
}
}
}
.mapStyle(.standard(elevation: .realistic))
}
}