Map4D Services SDK
针对 iOS 的 Map4D Services SDK,使用 C/C++ 和 Objective-C 编写。
安装
使用 CocoaPods。
- 更新 Cocoapods 本地仓库
pod repo update
- 添加到 Podfile
pod 'Map4dServices'
提供访问密钥
编辑 Info.plist
并添加 Map4d 服务访问密钥
<key>Map4dServicesAccessKey</key>
<string>YOUR_SERVICES_ACCESS_KEY</string>
使用
1. 路径服务
let options = MFDirectionOptions()
options.origin = CLLocation(latitude: 16.024634, longitude: 108.209217)
options.destination = CLLocation(latitude: 16.020179, longitude: 108.211212)
let service = MFDirectionService()
service.route(options: options) { (routes, error) in
// ...
}
2. 距离矩阵服务
let origins = [
MFWaypoint(coordinate: CLLocationCoordinate2D(latitude: 16.07019138675, longitude: 108.169161586766)),
MFWaypoint(coordinate: CLLocationCoordinate2D(latitude: 16.06705723761, longitude: 108.198086617386))
]
let destinations = [
MFWaypoint(coordinate: CLLocationCoordinate2D(latitude: 16.075225158325, longitude: 108.207924657001)),
MFWaypoint(coordinate: CLLocationCoordinate2D(latitude: 16.075367353035, longitude: 108.222074333984))
]
let options = MFDistanceMatrixOptions(origins: origins, destinations: destinations)
options.mode = .car
options.language = "vi"
MFDistanceMatrixService().getDistanceMatrix(options: options) { response, error in
// ...
}
3. 自动补全服务
let service = MFAutocompleteService()
let options = MFQueryAutocompletionOptions(text: "Landmark")
service.getQueryPredictions(options: options) { (places, error) in
// ...
}
4. 地理编码服务
let service = MFGeocodeService()
let options = MFGeocodeOptions()
options.location = CLLocation(latitude: 16.024634, longitude: 108.209217)
options.address = "31 Lê Văn Duyệt, Phường Nại Hiên Đông, Quận Sơn Trà, Thành Phố Đà Nẵng"
options.southWest = CLLocation(latitude: 16.056453967981348, longitude: 108.19387435913)
options.northEast = CLLocation(latitude: 16.093031550262133, longitude: 108.25927734375)
service.geocode(options: options){ places, error in
// ...
}
5. 地点服务
5.1 地点详情服务
let service = MFPlacesService()
service.getDetails(placeId: "5d0de3c7595b752b54a9a005") { (place, error) in
// ...
}
5.2 文本搜索服务
let service = MFPlacesService()
let options = MFTextSearchOptions(text: "Landmark")
service.textSearch(options: options) { (places, error) in
// ...
}
5.3 附近搜索服务
let service = MFPlacesService()
let options = MFNearbySearchOptions(location: CLLocationCoordinate2D(latitude: 16.0938083, longitude: 108.2285675), radius: 5000)
options.types = ["cafe"]
service.nearbySearch(options: options) { (places, error) in
// ...
}
5.4 视口搜索服务
let service = MFPlacesService()
let options = MFViewboxSearchOptions(southWest: CLLocationCoordinate2D(latitude: 16.056453967981348, longitude: 108.19387435913),
northEast: CLLocationCoordinate2D(latitude: 16.093031550262133, longitude: 108.25927734375))
options.text = "cafe"
service.viewboxSearch(options: options) { (places, error) in
// ...
}
许可协议
版权所有 © 2021 IOT Link Ltd. 保留所有权利。