一,效果图。

二,工程图。

三,代码。

ViewController.h

#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
#import "MapLocation.h" @interface ViewController : UIViewController
<MKMapViewDelegate>
{
MKMapView *_mapView;
NSString *addressString;
}
@end

ViewController.m

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view. //调用系统自带的高德地图 //显示当前某地的离线地图
_mapView = [[MKMapView alloc] init];
_mapView.frame = CGRectMake(0, 40, 320,400);
_mapView.delegate = self;
_mapView.mapType = MKMapTypeStandard;
[self.view addSubview:_mapView]; addressString=@"光启城";
NSLog(@"---addressString---%@",addressString); [self geocodeQuery]; } - (void)geocodeQuery{ if (addressString == nil || [addressString length] == 0) {
return;
} CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder geocodeAddressString:addressString completionHandler:^(NSArray *placemarks, NSError *error) { NSLog(@"查询记录数:%ld",[placemarks count]); if ([placemarks count] > 0) {
[_mapView removeAnnotations:_mapView.annotations];
} for (int i = 0; i < [placemarks count]; i++) { CLPlacemark* placemark = placemarks[i]; //调整地图位置和缩放比例
MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(placemark.location.coordinate, 10000, 10000);
[_mapView setRegion:viewRegion animated:YES]; MapLocation *annotation = [[MapLocation alloc] init];
annotation.streetAddress = placemark.thoroughfare;
annotation.city = placemark.locality;
annotation.state = placemark.administrativeArea;
annotation.zip = placemark.postalCode;
annotation.coordinate = placemark.location.coordinate; [_mapView addAnnotation:annotation];
}
}]; } #pragma mark Map View Delegate Methods
- (MKAnnotationView *) mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>) annotation { MKPinAnnotationView *annotationView
= (MKPinAnnotationView *)[_mapView dequeueReusableAnnotationViewWithIdentifier:@"PIN_ANNOTATION"];
if(annotationView == nil) {
annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation
reuseIdentifier:@"PIN_ANNOTATION"];
} annotationView.pinColor = MKPinAnnotationColorPurple;
annotationView.animatesDrop = YES;
annotationView.canShowCallout = YES; return annotationView;
} - (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
_mapView.centerCoordinate = userLocation.location.coordinate;
} - (void)mapViewDidFailLoadingMap:(MKMapView *)theMapView withError:(NSError *)error {
NSLog(@"error : %@",[error description]);
} @end

MapLocation.h

#import <MapKit/MapKit.h>

@interface MapLocation : NSObject<MKAnnotation>

//街道信息属性
@property (nonatomic, copy) NSString *streetAddress;
//城市信息属性
@property (nonatomic, copy) NSString *city;
//州、省、市信息
@property (nonatomic, copy) NSString *state;
//邮编
@property (nonatomic, copy) NSString *zip;
//地理坐标
@property (nonatomic, readwrite) CLLocationCoordinate2D coordinate; @end

MapLocation.m

//地图调用函数
#import "MapLocation.h" @implementation MapLocation - (NSString *)title {
return @"您的位置!";
}
- (NSString *)subtitle { NSMutableString *ret = [NSMutableString new];
if (_state)
[ret appendString:_state];
if (_city)
[ret appendString:_city];
if (_city && _state)
[ret appendString:@", "];
if (_streetAddress && (_city || _state || _zip))
[ret appendString:@" • "];
if (_streetAddress)
[ret appendString:_streetAddress];
if (_zip)
[ret appendFormat:@", %@", _zip]; return ret;
} @end

【代码笔记】iOS-离线地图的更多相关文章

  1. [转]ArcGIS移动客户端离线地图的几种解决方案

    原文地址:http://blog.chinaunix.net/uid-10914615-id-3023158.html 移动GIS中,通常将数据分为两大类:basemap layer和operatio ...

  2. [转]MBTiles 离线地图演示 - 基于 Google Maps JavaScript API v3 + SQLite

    MBTiles 是一种地图瓦片存储的数据规范,它使用SQLite数据库,可大大提高海量地图瓦片的读取速度,比通过瓦片文件方式的读取要快很多,适用于Android.IPhone等智能手机的离线地图存储. ...

  3. 支持WEB、Android、IOS的地图解决方案

    转自原文 支持WEB.Android.IOS的地图解决方案 工具链 GIS工具集 OpenGeo Suite 包含PostGIS, GeoServer, GeoWebCache, OpenLayers ...

  4. 【BIGEMAP一键离线地图服务】

    地址:http://www.bigemap.com/offlinemaps/ 首页 离线地图 代码示例 项目案例 开发文档 关于我们     [BIGEMAP一键离线服务] 1.快速搭建离线地图服务2 ...

  5. Web GIS 离线地图

    Web GIS 离线地图 1,基于瓦片的离线地图下载 博客园 阿凡卢 提供了离线地图的下载工具,下载地址:http://pan.baidu.com/s/1hqvQr7e 具体使用见 参考资料2 阿凡卢 ...

  6. iOS原生地图开发详解

    在上一篇博客中:http://my.oschina.net/u/2340880/blog/414760.对iOS中的定位服务进行了详细的介绍与参数说明,在开发中,地位服务往往与地图框架结合使用,这篇博 ...

  7. iOS原生地图开发进阶——使用导航和附近兴趣点检索

    iOS原生地图开发进阶——使用导航和附近兴趣点检索 iOS中的mapKit框架对国际化的支持非常出色.在前些篇博客中,对这个地图框架的基础用法和标注与覆盖物的添加进行了详细的介绍,这篇博客将介绍两个更 ...

  8. ArcGIS for Android示例解析之离线地图-----LocalTiledLayer

    转自:http://blog.csdn.net/wozaifeiyang0/article/details/7327423 LocalTiledLayer 看到这个标题是否是很激动,如题,该示例就是添 ...

  9. IOS开发笔记 IOS如何访问通讯录

    IOS开发笔记  IOS如何访问通讯录 其实我是反对这类的需求,你说你读我的隐私,我肯定不愿意的. 幸好ios6.0 以后给了个权限控制.当打开app的时候你可以选择拒绝. 实现方法: [plain] ...

随机推荐

  1. mysql的collation

    mysql的collation大致的意思就是字符序.首先字符本来是不分大小的,那么对字符的>, = , < 操作就需要有个字符序的规则.collation做的就是这个事情,你可以对表进行字 ...

  2. [JS] 使用RequireJS引用UMeditor

    UEditor是由百度web前端研发部开发所见即所得富文本web编辑器,具有轻量,可定制,注重用户体验等特点,开源基于MIT协议,允许自由使用和修改代码. 而UMeditor则是UEditor删减版. ...

  3. 检测WCF服务是否在线(动态执行WCF服务)

    在我们的系统里有多个wcf支撑.但是有的时候会莫名的停止,于是今天写了一个服务,定时去检测其他wcf服务是否在线.那么最简单的办法自然是引用其他wcf服务让vs给我们自动生成clientProxy然后 ...

  4. CHARFORMAT2 structure

    CHARFORMAT2 structure 包含在丰富的编辑控件中的字符格式设置的信息.charformat2是微软丰富的编辑CHARFORMAT结构2扩展.微软丰富的编辑2允许您使用结构与em_ge ...

  5. WinForm 容器控件

    容器控件: 布局:2个属性:Anchor:锁定位置Dock:填充位置一般Dock是与容器控件配合使用 Panel:就是一个区域,类似于DIV,可以独立布局,还可以让其它控件及容器在它的内部再次布局 F ...

  6. Qt的tablewidget行列头自适应宽度

    Qt构造一个TableWidget后,窗口最大化后,列头默认不能自适应宽度,研究了一下,Qt提供了两种方式来处理这个问题,如下:   1. 使用horizontalHeader()->setRe ...

  7. ASP.NET MVC 请求流程:Route

    1.RouteTable RouteTable翻译过来的意思就是路由表,一个Web应用程序具有一个全局的路由表,该路由表通过System.Web.Routiing.RouteTable的静态只读属性R ...

  8. CodeSnippet.info整体技术构架

    CodeSnippet.info整体架构 服务器端 Asp.NET MVC5 考察过MVC6,但是现在MVC6还不成熟,技术上不稳定,很多资料也比较少. 所以网站暂时使用MVC5.当然网站的大部分业务 ...

  9. 更改(修改)mysql自动增序列改变从1000开始

    更改(修改)mysql自动增序列改变从1000开始 ************************************************************************** ...

  10. MySQL Error Handling in Stored Procedures

    http://www.mysqltutorial.org/mysql-error-handling-in-stored-procedures/ mysql存储过程中的异常处理   定义异常捕获类型及处 ...