• 概述
  • 入门指导
  • API参考
  • 代码示例
IOS API简介
         天地图·四川IOS API ,不仅提供构建地图的基本接口,如地图显示、标注等,还提地图搜索,图层切换,定位,缓存清除等服务接口。用户使用天地图·四川 IOS API可以轻松地构建各类功能丰富、交互性强的地图应用程序。iOS 具有简单易用的界面、令人惊叹的功能,以及超强的稳定性,已经成为iPhone、iPad 和iPod touch 的强大基础。

天地图·四川 IOS API V1.0版具有如下特点:
1、提供全四川所有地点地名搜索,包括政府、交通、医疗、教育、住宿、美食、娱乐、景点等。
2、支持普通驾车路线搜索,同时还提供了带有途经点功能和障碍点功能的驾车路线检索。
3、通过GPS、wifi等多种定位方式,为您提供全方位的定位服务。随时掌握当前位置。
4、提供矢量、影像、路网与地名图层,按照您的浏览习惯可以自由切换。
5、离线地图包,便捷下载,轻松应用,节省流量,提高浏览速度,带给您全新的地图浏览体验。
6、随时随地采集感兴趣的位置,照相并上传到服务端,也可以随时随地查看之前上传的POI。


功能介绍
  • 基础地图服务支持在IOS移动设备中,矢量、影像、透明注记等地图服务显示。
  • 图层管理管理在IOS移动设备中地图显示方式,主要是影像,矢量,注记图层显示与切换操作。
  • 地图工具提供IOS移动设备中定位,全图,设置,查询,图层选择等对地图进行操作的工具。
  • 地名搜索提供IOS移动设备中包括地名模糊搜索、范围搜索,分类地名搜索服务。
ios api 介绍
        天地图四川 iOS API是一套基于iOS5.0及以上版本设备的应用程序接口,不仅提供展示地图的基本接口,如地图显示、标注等,还提供POI搜索、离线地图、定位服务接口。用户使用天地图四川API可以轻松地构建各类功能丰富、交互性强的地图应用程序。
功能介绍
        天地图四川IOS API主要包括以下内容:地图显示、覆盖物、离线地图、POI搜索、定位等等

        1.地图显示
        在手机上显示天地图四川的地图数据,包括矢量、影像等图层显示。天地图四川IOS API提供覆盖全球、数据精细的矢量地图和最高精度达0.5米的影像地图数据。所需类参见API参考类说明。
        2.覆盖物
        所有叠加或覆盖到地图的内容,统称为地图覆盖物,如自定义的标注、矢量图形元素等。天地图四川IOS API用户可以添加自己的覆盖物(标注层)到地图上,满足个性化需求,实现各种交互优良的地图应用。所需类参见API参考类说明。
        3.离线地图
        离线地图是指在线下载地图数据包,离线使用的技术。可以减少90%以上的流量,提高地图的浏览速度,优化浏览体验。天地图移动API为用户免费提供全国所有地级市的矢量和影像地图的离线地图数据包。所需类参见API参考类说明。
        4.POI搜索
        提供关键字搜索、分类搜索和周边搜索。所需类参见API参考类说明。
        5.定位服务
        天地图四川IOS API支持定位服务,拥有GPS、网络等多种定位方式,定位更准确,轻松获取用户当前位置和移动方向。所需类参见API参考类说明。
使用指南
        使用要求:
                iOS 5.0 及以上版本的iOS设备。
        使用步骤:
                1.下载运行AGSRuntimeSDKiOSv2.3.pkg,安装arcgis sdk。
                2.打开Xcode,新建一个IOS项目。





                3.将SCGCFramework.framework拷贝到项目文件夹下,在项目中添加引用。



                4.添加以下库文件
        CoreGraphics.framework
        CoreLocation.framework
        CoreText.framework
        Foundation.framework
        libc++.dylib
        libstdc++.dylib
        libz.dylib
        QuartzCore.framework
        MediaPlayer.framework
        MobileCoreServices.framework
        OpenGLES.framework
        Security.framework
        UIKit.framework
        CFNetwork.framework
        SystemConfiguration.framework
        CoreGraphics.framework
        libz.1.2.3.dylib
        libsqlite3.0.dylib



                5.添加所需资源文件
        右键点击项目,选择Add Files to “HelloWorld”,添加SCGCFramework.framework/Resources下的iTile.db,ArcGIS.bundle文件到项目中



                6.配置项目
        在项目Build Settings中Framework Search Paths添加$(HOME)/Library/SDKs/ArcGIS/**

                7.添加地图界面
        打开XIB文件,拖动一个View到界面上,将View的Class改为AGSMapView,并添加代码接口







                8.添加图层

        //在头文件中添加引用
        #import <SCGCFramework/scgc.h>
        //在视图控制器加载时添加图层
        - (void)viewDidLoad
        {
            [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
        SCGISTilemapServerLayer * tilemapLayer = 
        [[SCGISTilemapServerLayer alloc] initWithServiceUrlStr:
        @"http://www.scgis.net.cn/imap/imapserver/defaultrest/services/scmobile_dlg/" Token:nil];
        //如果服务加密就需要token
            [self.mapView addMapLayer:tilemapLayer withName:@"dlg"];
        }
        

                9.运行结果

 

IOS API 参考



SCGISTilemapServerLayer 类

此类主要用于加载四川省基础地理中心发布的REST风格的切片地图服务。


构造函数


构造函数说明参数说明
initWithServiceUrlStr:(NSString*) aurlStr Token:(NSString*) atoken; 创建一个切片图层的实例

aurlStr:切片服务的

atoke:令牌

initWithServiceUrlStr:(NSString*) aurlStr Token:(NSString*) atoken CacheType:(SCGISTilemapCacheType) acacheType; 创建一个切片图层的实例

aurlStr:切片服务的URL地址

atoke:令牌

acacheType:使用缓存类型


SCGISTilemapCacheType 瓦片缓存类型


缓存类型说明
SCGISTilemapCacheTypeNone 不使用缓存
SCGISTilemapCacheTypeArcGISFile 使用本地文件格式进行缓存
SCGISTilemapCacheTypeSqliteDB 使用数据库格式进行缓存


SCGISNameSearchTask 类

该类用于POI搜索


参数:


SCGISNameSearchParams


参数名参数类型参数说明
urlStr String 查询服务的地址
Keyword String 查询关键字
Typecode String 分类代码
Statepac String 市州代码
Countypac String 区县代码
Isonlyname Bool 是否只查询名称
Boundingbox AGSEnvelope 查询的范围
StartIndex Int 查询开始编号
StopIndex Int 查询结束编号
Token String 令牌
Content Id 查询上下文

SCGISNameBufferSearchParams


参数名参数类型参数说明
urlStr String 查询服务的地址
Keyword String 查询关键字
Typecode String 分类代码
center AGSPoint 查询中心点
radius int 查询半径,单位米
radStartIndexius int 查询开始编号
StopIndex int 查询结束编号
Token String 令牌
Content Id 查询上下文

方法:


方法名说明
-(NSDictionary*) getMeta:(NSString*) urlStr Token:(NSString*)token 地名服务元数据查询,直接返回NSDictionary对象
getMeta:(NSString*) urlStr Token:(NSString*)token Content:(id)content 地名服务元数据查询,通过委托进行返回
search:(SCGISNameSearchParams*) params 地名查询
searchCount:(SCGISNameSearchParams*) params 地名个数查询
bufferSearch:(SCGISNameBufferSearchParams*) params 周边查询
bufferSearchCount:(SCGISNameBufferSearchParams*) params 周边个数查询

委托


SCGISNameSearchTaskDelegate


委托名参数说明委托说明
-(void)SCGISNameSearchTaskDidJsonCallback:(NSDictionary*) jsonDic Content:(id)content

jsonDic:返回的数据对象

content:查询上下文

进行数据查询成功后调用
-(void)SCGISNameSearchTaskDidFail:(NSError*) error responseData:(NSData*)data Content:(id)content

Error:查询错误信息

Data:服务返回数据

Content:查询上下文

调用服务错误或者服务查询返回错误信息时调用

IOS API 示例



创建地图显示



代码:


        #import <UIKit/UIKit.h>
        #import <SCGCFramework/scgc.h>

        @interface ViewController : UIViewController
        @property (strong, nonatomic) IBOutlet AGSMapView *mapView;

        @end
        

实现文件:

        #import "ViewController.h"

        @implementation ViewController
        @synthesize mapView;

        - (void)didReceiveMemoryWarning
        {
            [super didReceiveMemoryWarning];
            // Release any cached data, images, etc that aren't in use.
        }

        #pragma mark - View lifecycle


        - (void)viewDidLoad
        {
            [super viewDidLoad];
	        // Do any additional setup after loading the view, typically from a nib.
            SCGISTilemapServerLayer * tilemapLayer = [[SCGISTilemapServerLayer alloc] initWithServiceUrlStr:@"http://www.scgis.net.cn/iMap/iMapServer/DefaultRest/services/newtianditudlg/" Token:nil];
            [self.mapView addMapLayer:tilemapLayer withName:@"dlg"];
        }
        @end
        


地图标注



代码:


申明文件:

        #import <UIKit/UIKit.h>
        #import <SCGCFramework/scgc.h>

        @interface ViewController : UIViewController
        @property (strong, nonatomic) IBOutlet AGSMapView *mapView;

        @end
        

实现文件:

        #import "ViewController.h"

        @implementation ViewController
        @synthesize mapView;

        - (void)didReceiveMemoryWarning
        {
            [super didReceiveMemoryWarning];
            // Release any cached data, images, etc that aren't in use.
        }

        #pragma mark - View lifecycle


        - (void)viewDidLoad
        {
            [super viewDidLoad];
	        // Do any additional setup after loading the view, typically from a nib.
            SCGISTilemapServerLayer * tilemapLayer = [[SCGISTilemapServerLayer alloc] initWithServiceUrlStr:@"http://www.scgis.net.cn/iMap/iMapServer/DefaultRest/services/newtianditudlg/" Token:nil];
            [self.mapView addMapLayer:tilemapLayer withName:@"dlg"]; 
    
            AGSGraphicsLayer* graphicsLayer = [AGSGraphicsLayer graphicsLayer];
	        [self.mapView addMapLayer:graphicsLayer withName:@"Graphics Layer"];
    
            AGSEnvelope *enve=[AGSEnvelope envelopeWithXmin:104 ymin:30 xmax:105 ymax:31 spatialReference:self.mapView.spatialReference];
            AGSFillSymbol *symbol=[[AGSFillSymbol alloc] init];
            symbol.color=[UIColor redColor];
            AGSGraphic* graphic = [AGSGraphic graphicWithGeometry:enve symbol:symbol attributes:nil infoTemplateDelegate:nil];
            [graphicsLayer addGraphic:graphic];

        }
        @end
        


定位



用于调用检索地名地址的服务。


申明文件:

        #import <UIKit/UIKit.h>
        #import <SCGCFramework/scgc.h>

        @interface ViewController : UIViewController
        @property (strong, nonatomic) IBOutlet AGSMapView *mapView;

        @end
        

实现文件:

        #import "ViewController.h"

        @implementation ViewController
        @synthesize mapView;

        - (void)didReceiveMemoryWarning
        {
            [super didReceiveMemoryWarning];
            // Release any cached data, images, etc that aren't in use.
        }

        #pragma mark - View lifecycle


        - (void)viewDidLoad
        {
            [super viewDidLoad];
	        // Do any additional setup after loading the view, typically from a nib.
            SCGISTilemapServerLayer * tilemapLayer = [[SCGISTilemapServerLayer alloc] initWithServiceUrlStr:@"http://www.scgis.net.cn/iMap/iMapServer/DefaultRest/services/newtianditudlg/" Token:nil];
        [self.mapView addMapLayer:tilemapLayer withName:@"dlg"];

        [self.mapView.gps start];
        }
        @end
        


POI查询



代码:


申明文件:

        #import <UIKit/UIKit.h>
        #import <SCGCFramework/scgc.h>

        @interface ViewController : UIViewController<SCGISNameSearchTaskDelegate>{
            AGSGraphicsLayer* graphicsLayer;
        }
        @property (strong, nonatomic) IBOutlet AGSMapView *mapView;

        @end
        

实现文件:

        #import "ViewController.h"

        @implementation ViewController
        @synthesize mapView;
        #import <UIKit/UIKit.h>
        #import <SCGCFramework/scgc.h>

        @interface ViewController : UIViewController<SCGISNameSearchTaskDelegate>{
            AGSGraphicsLayer* graphicsLayer;
        }
        @property (strong, nonatomic) IBOutlet AGSMapView *mapView;

        @end

        - (void)didReceiveMemoryWarning
        {
            [super didReceiveMemoryWarning];
            // Release any cached data, images, etc that aren't in use.
        }

        #pragma mark - View lifecycle


        - (void)viewDidLoad
    {
            [super viewDidLoad];
	        // Do any additional setup after loading the view, typically from a nib.
            SCGISTilemapServerLayer * tilemapLayer = [[SCGISTilemapServerLayer alloc] initWithServiceUrlStr:@"http://www.scgis.net.cn/iMap/iMapServer/DefaultRest/services/newtianditudlg/" Token:nil];
            [self.mapView addMapLayer:tilemapLayer withName:@"dlg"];
    
            graphicsLayer = [AGSGraphicsLayer graphicsLayer];
	        [self.mapView addMapLayer:graphicsLayer withName:@"Graphics Layer"];
    
            SCGISNameSearchParams *params=[[SCGISNameSearchParams alloc] init];
            params.urlStr=@"http://www.scgis.net.cn:5506/iMap/iMapServer/DefaultRest/services/newtianditunamesearch/";
            params.token=nil;
            params.keyword=@"学校";
            params.startIndex=0;
            params.stopIndex=10;
            params.statePac=@"5101";
    
            SCGISNameSearchTask *task=[[SCGISNameSearchTask alloc] init];
            task.delegate=self;
    
            [task search:params];
        }

        #pragma mark - SCGISNameSearchTaskDelegate
        -(void)SCGISNameSearchTaskDidFail:(NSError *)error responseData:(NSData *)data Content:(id)content{
    
        }
        -(void)SCGISNameSearchTaskDidJsonCallback:(NSDictionary *)jsonDic Content:(id)content{
            NSNumber *number=[jsonDic objectForKey:@"success"];
            if ([number intValue]==1) {
                NSDictionary *messageDic=[jsonDic objectForKey:@"message"];
                NSArray *columnsList=[messageDic objectForKey:@"columns"];
                NSArray *featuresList=[messageDic objectForKey:@"features"];
                if (featuresList&&[featuresList count]>0) {
                    //定义一个点样式
                    //AGSSimpleMarkerSymbol *myMarkerSymbol =[AGSSimpleMarkerSymbol simpleMarkerSymbol];
                    AGSPictureMarkerSymbol *myMarkerSymbol =[AGSPictureMarkerSymbol pictureMarkerSymbolWithImageNamed:@"pushpin.png"];
                    myMarkerSymbol.xoffset=10;
                    myMarkerSymbol.yoffset=10;
                    double minx=180,miny=90,maxx=0,maxy=0;
                    for (int i=0; i<[featuresList count]; i++) {
                        NSDictionary *feaDic=[featuresList objectAtIndex:i];
                        NSArray *attr=[feaDic objectForKey:@"attributes"];
                        AGSPoint* myMarkerPoint =[AGSPoint pointWithX:[[attr objectAtIndex:1] doubleValue]
                                                                    y:[[attr objectAtIndex:2] doubleValue]
                                                    spatialReference:self.mapView.spatialReference];
                
                        if (myMarkerPoint.x<minx) {
                            minx=myMarkerPoint.x;
                        }
                        if (myMarkerPoint.x>maxx) {
                            maxx=myMarkerPoint.x;
                        }
                        if (myMarkerPoint.y<miny) {
                            miny=myMarkerPoint.y;
                        }
                        if (myMarkerPoint.y>maxy) {
                            maxy=myMarkerPoint.y;
                        }
                
                        //attributes
                        NSMutableDictionary *attrDic=[NSMutableDictionary dictionaryWithCapacity:10];
                        [attrDic setValue:[NSNumber numberWithInt:1] forKey:@"gtype"];
                        for(int j=0;j<[columnsList count];j++){
                            NSDictionary *colDic=[columnsList objectAtIndex:j];
                            NSString *key=[colDic objectForKey:@"columnName"];
                            [attrDic setObject:[attr objectAtIndex:j] forKey:key];
                        }
                
                        //geometry created earlier
                        AGSGraphic* myGraphic =[AGSGraphic graphicWithGeometry:myMarkerPoint
                                                                        symbol:myMarkerSymbol
                                                                    attributes:attrDic
                                                        infoTemplateDelegate:nil];
                        [attrDic setObject:myGraphic forKey:@"graphic"];
                //Add the graphic to the Graphics layer
                [graphicsLayer addGraphic:myGraphic];
                }
            }
        }
            [graphicsLayer dataChanged];
        }
        @end