最新文档地址:https://developers.arcgis.com/ios/latest/swift/guide/introduction.htm

10.2.5的文档

安装集成

可以选择使用手动集成或cocoapods:

手动集成(不推荐)

1). 选择合适版本下载 https://developers.arcgis.com/downloads/apis-and-sdks?product=ios 2). 安装

201804045828gis安装器.png

集成方法略

cocoapods集成

pod 'ArcGIS-Runtime-SDK-iOS', '10.2.5'

发现报错:

➜  ArcGisDemo pod update --no-repo-update
Update all pods
Analyzing dependencies
Downloading dependencies
Installing ArcGIS-Runtime-SDK-iOS (10.2.5)

[!] Error installing ArcGIS-Runtime-SDK-iOS
[!] /usr/bin/curl -f -L -o /var/folders/bl/cg_1b56575d60hz_3ctbcc6m0000gn/T/d20180404-22788-14vccuo/file.zip http://esri.box.com/shared/static/aa3e5u04sakyshphc9ooqizvyse7b8iv.zip --create-dirs --netrc-optional

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
curl: (56) Recv failure: Connection reset by peer


[!] Automatically assigning platform ios with version 11.1 on target ArcGisDemo because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.

发现http://esri.box.com/shared/static/aa3e5u04sakyshphc9ooqizvyse7b8iv.zip浏览器可以下载,但是curl不行。 仔细一看应该是被墙了。。。 设置下curl的代理吧。

参考: https://github.com/mrdulin/blog/issues/18 https://blog.fazero.me/2015/09/15/让终端走代理的几种方法/

在当前终端运行以下命令,那么wget curl 这类网络命令都会经过ss代理(只对当前终端有效,退出就不行了)

➜  ~ export ALL_PROXY=socks5://127.0.0.1:1086

➜  ~ curl ip.cn
当前 IP:35.229.181.10 来自:美国 Google

重新pod udpate --no-repo-update 完美解决。

简陋的demo

class ViewController: UIViewController {

    @IBOutlet weak var mapView: AGSMapView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        //使用  ArcGIS Online map service
        //Add a basemap tiled layer
        let urlString = "http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer"
        let tiledLayer = AGSTiledMapServiceLayer(url:URL.init(string: urlString))
        self.mapView.addMapLayer(tiledLayer, withName: "Basemap Tiled Layer")
        self.mapView.layerDelegate = self
        self.mapView.touchDelegate = self
    }
}

//处理各种点击事件
extension ViewController:AGSMapViewTouchDelegate{
}

extension ViewController:AGSMapViewLayerDelegate{
    
    func mapViewDidLoad(_ mapView: AGSMapView!) {
        print("mapViewDidLoad")
        
        mapView.locationDisplay.startDataSource()
    }
}