ArcGIS proporciona a los usuarios dos cuadros de viñetas, uno es AGSCallout:
Este cuadro emergente proporciona una visualización de información simple y se puede activar otro evento después de hacer clic en el icono i.
El código utilizado para recuperar elementos de capa en combinación con clics:
- (void)geoView:(AGSGeoView *)geoView didTapAtScreenPoint:(CGPoint)screenPoint mapPoint:(AGSPoint *)mapPoint {
//进行i查询,tolerance大致是指精确的范围,api有英文解释
__weak __typeof(self)weakSelf = self;
[geoView identifyLayersAtScreenPoint:screenPoint tolerance:2.0 returnPopupsOnly:NO completion:^(NSArray<AGSIdentifyLayerResult *> * _Nullable identifyResults, NSError * _Nullable error) {
if (identifyResults.count) {
//得到的i查询结果一般是最大层的图层信息,这里得到的是动态图层信息
AGSIdentifyLayerResult *result = identifyResults.firstObject;
if (result.sublayerResults.count) {
//当然,咱们要的是图层上的元素信息,此处取第一个
AGSIdentifyLayerResult *oneLayer = result.sublayerResults.firstObject;
id<AGSGeoElement> geo = oneLayer.geoElements.firstObject;
if (geo.geometry.geometryType == AGSGeometryTypePolyline || geo.geometry.geometryType == AGSGeometryTypePolygon) {
[weakSelf.mapView setViewpointGeometry:geo.geometry padding:1.0 completion:^(BOOL finished) {
}];
//计算面积
double areaNumber = [AGSGeometryEngine geodeticAreaOfGeometry:geo.geometry areaUnit:[AGSAreaUnit unitWithUnitID:AGSAreaUnitIDSquareMeters] curveType:AGSGeodeticCurveTypeShapePreserving];
//标题取图层元素名称
weakSelf.mapView.callout.title = oneLayer.layerContent.name;
weakSelf.mapView.callout.detail = [NSString stringWithFormat:@"面积:%.2f平米",areaNumber];
// weakSelf.mapView.callout.accessoryButtonType = UIButtonTypeCustom;//去掉自带的i图标
// weakSelf.mapView.callout.accessoryButtonImage = nil;//自定义i图标
weakSelf.mapView.callout.delegate = weakSelf;
[weakSelf.mapView.callout showCalloutAt:geo.geometry.extent.center screenOffset:CGPointZero rotateOffsetWithMap:YES animated:YES];
}
}
}
}];
}
AGSCallout proporciona algunos eventos de devolución de llamada de delegado, como hacer clic en el ícono i, consulte AGSCalloutDelegate para obtener más información.
Otro es AGSPopup:
Esta pantalla emergente puede contener varias páginas y más información.
Usa el código:
- (void)geoView:(AGSGeoView *)geoView didTapAtScreenPoint:(CGPoint)screenPoint mapPoint:(AGSPoint *)mapPoint {
//进行i查询,tolerance大致是指精确的范围,api有英文解释
__weak __typeof(self)weakSelf = self;
[geoView identifyLayersAtScreenPoint:screenPoint tolerance:2.0 returnPopupsOnly:NO completion:^(NSArray<AGSIdentifyLayerResult *> * _Nullable identifyResults, NSError * _Nullable error) {
if (identifyResults.count) {
//得到的i查询结果一般是最大层的图层信息,这里得到的是动态图层信息
AGSIdentifyLayerResult *result = identifyResults.firstObject;
if (result.sublayerResults.count) {
//当然,咱们要的是图层上的元素信息,此处取第一个
AGSIdentifyLayerResult *oneLayer = result.sublayerResults.firstObject;
id<AGSGeoElement> geo = oneLayer.geoElements.firstObject;
if (geo.geometry.geometryType == AGSGeometryTypePolyline || geo.geometry.geometryType == AGSGeometryTypePolygon) {
AGSPopup *pop = [AGSPopup popupWithGeoElement:geo];//创建一个pop
AGSPopupsViewController *popCon = [[AGSPopupsViewController alloc] initWithPopups:@[pop]];//一个pop控制器可以显示多个pop
popCon.delegate = self;
[weakSelf presentViewController:popCon animated:YES completion:nil];
}
}
}
}];
}
El delegado AGSPopupsViewControllerDelegate proporciona la devolución de llamada del evento de clic del botón de finalización:
-(void)popupsViewControllerDidFinishViewingPopups:(AGSPopupsViewController *)popupsViewController {
[popupsViewController dismissViewControllerAnimated:YES completion:nil];
}