| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx

IOS基础学习之添加地图定位方法

0
C/C++ Go iOS开发 IOS学习 ci 10926 次浏览
IOS开发中,使用地图只需要新建一个MKMapView,addSubView即可。如下:
1、添加地图
1.1 新一个Single View app ,选择默认项,创建后,在ViewController.h 
  1. #import <UIKit/UIKit.h>  
  2. #import <MapKit/MapKit.h>  
  3. #import <CoreLocation/CoreLocation.h>  
  4.   
  5. @interface ViewController : UIViewController   
  6. <MKMapViewDelegate, CLLocationManagerDelegate> {  
  7.     MKMapView *map;  
  8.     CLLocationManager *locationManager;  
  9. }  
  10. @end
复制代码

1.2 在ViewController.m中添加
  1. - (void)viewDidLoad  
  2. {  
  3.     map = [[MKMapView alloc] initWithFrame:[self.view bounds]];  
  4.     map.showsUserLocation = YES;  
  5.     map.mapType = MKMapTypeSatellite;  
  6.     [self.view addSubview:map];  
  7.   
  8.   
  9.     [super viewDidLoad];  
  10.     // Do any additional setup after loading the view, typically from a nib.  
  11. }  
复制代码

运行即可

2、定位到指定经纬度

  1. CLLocationCoordinate2D coords = CLLocationCoordinate2DMake(39.915352,116.397105);  
  2.       
  3.     float zoomLevel = 0.02;  
  4.     MKCoordinateRegion region = MKCoordinateRegionMake(coords, MKCoordinateSpanMake(zoomLevel, zoomLevel));  
  5.     [map setRegion:[map regionThatFits:region] animated:YES];  
  6.          
复制代码

点此查看更多IOS学习视频教程。

1个答案

0

It offers user-defined variable-type columns, triggers, views and stored procedures. MySQL offers a wide range of data types to meet application requirements. As https://www.paisley.org.uk/2022/01/how-to-find-the-best-uk-essay-writing-service/ explain It is widely used as a database backend as it is available in different platforms, including Linux, Windows, Unix, Palm, Mac OS, etc.