SGTileLayer 0.0.5

SGTileLayer 0.0.5

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最后发布2017年5月

crash_wu 维护。



  • 作者
  • 吴小星

作者

吴小星, [email protected]

描述

提供天地图瓦片图层加载,百度地图瓦片图层加载,以及其他 TileLayer 类型图层加载等功能。在图层加载时,提供缓存图层功能。

使用

'#import <SGTileLayer/SGTileLayerHeader.h>'
//引入头文件到项目中

加载天地图、百度地图瓦片

SGTileLayerUtil

/**
*  @author crash         [email protected]   , 16-08-23 10:08:01
*
*  @brief  单列
*
*  @return 类的对象
*/
+(nonnull instancetype)sharedInstance;

/**
*  @author crash         [email protected]   , 16-08-23 10:08:31
*
*  @brief  清除天地图图层
*
*  @param mapView 地图容器
*/
-(void)clearTdtLayer:(nonnull AGSMapView * ) mapView;


/**
*  @author crash         [email protected]   , 16-08-23 10:08:49
*
*  @brief  加载天地图
*
*  @param tdtLayerType 天地图瓦片类型

*  @param mapView      地图容器
*/
-(void)loadTdtTileLayer:(WMTSLayerTypes) tdtLayerType  andMapView :(nonnull AGSMapView * ) mapView;

/**
*  @author crash         [email protected]   , 16-08-23 10:08:54
*
*  @brief  加载百度地图切片
*
*  @param mapView 地图
*/
-(void)loadBdTileLayer:(nonnull AGSMapView *)mapView;

/**
*  @author crash         [email protected]   , 16-08-23 10:08:00
*
*  @brief  清除百度瓦片图层
*
*  @param mapView 地图容器
*/
-(void)clearBdLayer:(nonnull AGSMapView *)mapView;


/**
*  @author crash         [email protected]   , 16-08-23 10:08:35
*
*  @brief  获取天地图当前图层级别
*
*  @param tdtLayer 天地图图层
*
*  @return 天地图当前图层级别
*/
-(NSInteger)currentLevel:(nonnull SouthgisTdt_TileLayer *)tdtLayer;

 /**
 *  @author crash         [email protected]   , 16-09-01 17:09:01
 *
 *  @brief  加载天地图底图(CGCS2000 坐标系)
 *
 *  @param mapView 地图
 */
-(void)loadTdtCGCS2000:(nonnull AGSMapView *)mapView;

/**
 *  @author crash         [email protected]   , 16-09-05 15:09:14
 *
 *  @brief  加载天地图影像底图
 *
 *  @param mapView 当前地图
 */
-(void) loadTdtImageCGCS2000:(nonnull AGSMapView *) mapView;


/**
 *  @author crash         [email protected]   , 16-09-05 15:09:05
 *
 *  @brief  清除天地图CGCS2000图层
 *
 *  @param mapView 当前地图
 */
-(void)clearCGCS2000:(nonnull AGSMapView *)mapView;

例如:

加载天地图
[[SGTileLayerUtil sharedInstance] loadTdtTileLayer:WMTS_VECTOR_2000 andMapView:self.mapView];

//加载天地图国标2000图层
[[SGTileLayerUtil sharedInstance]loadTdtCGCS2000:self.mapView];

加载百度地图
[[SGTileLayerUtil sharedInstance] loadBdTileLayer:self.mapView];

加载其他 TileLayer 图层服务

Southgis_TiledServiceLayer

/**
* @author Jeremy, 16-03-01 14:03:04
*
* 初始化
*
* @param url   图层地址
*
* @return 服务图层
*/
- (instancetype)initTiledServiceLayerURL:(NSString *)url;

加载 WMTS 服务图层

SGSWMTSInfo

/**
*  根据 GetCapabilities URL 实例化
*
*  如果实例化成功则自动开始进行 GetCapabilities,可以通过代理方法获取请求结果
*  DPI 默认使用 96 dots/inch
*
*  @param url GetCapabilities 请求地址
*
*  @return SGSWMTSInfo or nil
*/
- (instancetype)initWithURLString:(NSString *)url delegate:(id<SGSWMTSInfoDelegate>)delegate;

/**
*  根据 GetCapabilities URL 实例化
*
*  如果实例化成功则自动开始进行 GetCapabilities,可以通过代理方法获取请求结果
*
*  @param url GetCapabilities 请求地址
*  @param dpi 切片 DPI
*
*  @return SGSWMTSInfo or nil
*/
- (instancetype)initWithURLString:(NSString *)url tileDPI:(NSUInteger)dpi delegate:(id<SGSWMTSInfoDelegate>)delegate;

例如:

-(void)viewDidAppear:(BOOL)animated{
     [super viewDidAppear:animated];

   SGSWMTSInfo  * _info = [[SGSWMTSInfo alloc] initWithURLString:@"http://t0.tianditu.com/vec_c/wmts" delegate:self];
}

#pragma mark - SGSWMTSInfoDelegate
- (void)sgsWMTSInfoDidLoad:(SGSWMTSInfo *)wmtsInfo {
    SGSWMTSLayerInfo *layerInfo = wmtsInfo.layerInfos.firstObject;
    if (layerInfo) {
        SGSWMTSLayer *layer = [wmtsInfo wmtsLayerWithLayerInfo:layerInfo];
        [_mapView addMapLayer:layer];

        [layer loadWMTSTileAndUsingCache:YES];
    } else {
        NSLog(@"tuceng wei kong");
    }
}

设置

设置 Framework search Patchs 以及 Other Links


  • 1.选择项目工程文档; 2.选择 Build Setting 菜单; 3.选择 Frame work search Patchs,并且添加 '$(inherited)' 4.选择 Others Links,并且添加 ‘$(inherited)'*

如图:

修改 SGTileLayer.framework 编译属性

  • 由于 ArcgisSDK 是静态库的原因,所有 pod Install,或者 pod update 后,要更改 SGTileLayer.framework 编译属性。1.点击打开 Pods 项目 2.选择 SGTileLayer.framework 3.选择 Build Settings 菜单栏; 4.搜索 Mach-o 编译库选项; 5.修改 Mach-o 为 Static Library 6.每次 pod install 或者 pod update 后,都要更改上述的编译配置信息;

如下图所示:

示例

要运行示例项目,请首先克隆仓库,然后从 Example 目录运行 pod install

加载天地图

加载百度地图

加载 WMTS

需求

ArcGIS-Runtime-SDK-iOS for version 10.2.5

许可证

SGTileLayer遵循MIT许可证。有关更多信息,请参阅LICENSE文件。