七、ArcGIS Runtime SDK for iOS 100.2.1教程系列之地理檢索

ArcGIS直接提供了地理檢索api,但是這個功能需要依託後臺服務發佈GeocodeServer服務

__weak __typeof(self)weakSelf = self;
    if (!self.locatorTask) {
        self.locatorTask = [[AGSLocatorTask alloc] initWithURL:[NSURL URLWithString:@"https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"]];
    }
    if (!self.geoParams) {
        self.geoParams = [[AGSGeocodeParameters alloc] init];
        self.geoParams.resultAttributeNames = @[@"*"];
        self.geoParams.minScore = 75;//匹配度
//        self.geoParams.outputSpatialReference = self.mapView.spatialReference;
//        self.geoParams.preferredSearchLocation = AGSPointMake(530381, 392550, self.mapView.spatialReference);
//        self.geoParams.searchArea = self.dynamicLayer.fullExtent;
    }
    [self.locatorTask loadWithCompletion:^(NSError * _Nullable error) {
        if (!error) {
            [weakSelf.locatorTask geocodeWithSearchText:@"Disneyland" parameters:weakSelf.geoParams completion:^(NSArray<AGSGeocodeResult *> * _Nullable geocodeResults, NSError * _Nullable error) {
                
            }];
        }
    }];

該API還是比較淺顯的,使用比較方便。

今天突然發現其實官方給出了一份開源的詳細使用代碼,還發布到了AppStore,git直達:https://github.com/Esri/arcgis-runtime-samples-ios,大家可以自行下載過來參考,只不過是swift版本的。

等後續開發中發現更多實用性強,坑比較多的功能時再持續更新博客,謝謝關注!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章