如何在 iOS 中以编程方式下载地图
How to download map programmatically in iOS
正在处理 Mapkit 框架。
我想通过编程方式下载地图的特定区域。
并且还想在 offline.How 中显示下载的地图,我可以这样做吗?
任何人都可以帮助我,将不胜感激。
谢谢。
简而言之,MapKit 无法通过。
我已经使用了第三方 SDK。请查看下面的 link
https://www.mapbox.com/developers/
Objective C
@import Mapbox;
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
MGLMapView *mapView = [[MGLMapView alloc] initWithFrame:self.view.bounds];
mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
// set the map's center coordinates and zoom level
[mapView setCenterCoordinate:CLLocationCoordinate2DMake(40.7326808, -73.9843407)
zoomLevel:12
animated:NO];
[self.view addSubview:mapView];
}
@end
Swift
import Mapbox
class ViewController: UIViewController, MGLMapViewDelegate {
override func viewDidLoad() {
super.viewDidLoad()
let mapView = MGLMapView(frame: view.bounds)
mapView.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
// set the map's center coordinate
mapView.setCenterCoordinate(CLLocationCoordinate2D(latitude: 40.7326808,
longitude: -73.9843407),
zoomLevel: 12, animated: false)
view.addSubview(mapView)
}
}
详细文档请参考:https://www.mapbox.com/help/first-steps-ios-sdk/
请注意它不是免费的:https://www.mapbox.com/pricing/
正在处理 Mapkit 框架。
我想通过编程方式下载地图的特定区域。
并且还想在 offline.How 中显示下载的地图,我可以这样做吗?
任何人都可以帮助我,将不胜感激。
谢谢。
简而言之,MapKit 无法通过。
我已经使用了第三方 SDK。请查看下面的 link
https://www.mapbox.com/developers/
Objective C
@import Mapbox;
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
MGLMapView *mapView = [[MGLMapView alloc] initWithFrame:self.view.bounds];
mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
// set the map's center coordinates and zoom level
[mapView setCenterCoordinate:CLLocationCoordinate2DMake(40.7326808, -73.9843407)
zoomLevel:12
animated:NO];
[self.view addSubview:mapView];
}
@end
Swift
import Mapbox
class ViewController: UIViewController, MGLMapViewDelegate {
override func viewDidLoad() {
super.viewDidLoad()
let mapView = MGLMapView(frame: view.bounds)
mapView.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
// set the map's center coordinate
mapView.setCenterCoordinate(CLLocationCoordinate2D(latitude: 40.7326808,
longitude: -73.9843407),
zoomLevel: 12, animated: false)
view.addSubview(mapView)
}
}
详细文档请参考:https://www.mapbox.com/help/first-steps-ios-sdk/
请注意它不是免费的:https://www.mapbox.com/pricing/