iOS开发之离线地图核心代码

2020-01-15 14:35:14丽君

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开发频道。