arcgis的图层关系
底图、图层、graphic图层,
底图也是一个图层数组,但是注意在ios中底图最先添加的那个图层能够影响整个底图的显示范围,这确实让人很无语
[self.mapView.map.basemap.baseLayers addObject:layer];
图层,这是一个可变数组无疑,我们可以随意切换,但是注意,一定不要添加相同的图层,这会导致图层异常。
[self.mapView.map.operationalLayers addObject:layer];
图层类型有很多,要学会分辨不同图层,不同图层加载速度是不同的image、tile、
AGSArcGISTiledLayer、ArcGISMapImageLayer等
图层可以随意挑换显示顺序及显示透明度
绘制点
UIImage *markerImage = [UIImage imageNamed:@”hq_search_location”];
AGSPictureMarkerSymbol *pictuerMarkerSymbol = [[AGSPictureMarkerSymbol alloc] initWithImage:markerImage];
pictuerMarkerSymbol.leaderOffsetY = markerImage.size.height / 2;
pictuerMarkerSymbol.offsetY = markerImage.size.height / 2;
self.searchGraphic = [[AGSGraphic alloc] initWithGeometry:poi.geometry symbol:pictuerMarkerSymbol attributes:@{@”name”:poi.poiname,@”address”:poi.address}];
[self.graphicsOverlay.graphics addObject:self.searchGraphic];
[self.mapView setViewpointCenter:(AGSPoint )poi.geometry scale:10000 completion:nil];
绘制线
AGSSimpleLineSymbol simpleLineSymbol = [[AGSSimpleLineSymbol alloc] initWithStyle:AGSSimpleLineSymbolStyleSolid color:[UIColor redColor] width:10];
self.searchGraphic = [[AGSGraphic alloc] initWithGeometry:road.geometry symbol:simpleLineSymbol attributes:@{@”name”:road.roadname,@”address”:road.address}];
[self.graphicsOverlay.graphics addObject:self.searchGraphic];
AGSViewpoint viewpoint = [self getGeometryViewpoint:road.geometry];
[self.mapView setViewpoint:viewpoint completion:nil];
绘制面
AGSSimpleLineSymbol simpleLineSymbol = [[AGSSimpleLineSymbol alloc] initWithStyle:AGSSimpleLineSymbolStyleSolid color:[UIColor systemBlueColor] width:10];
AGSSimpleFillSymbol *fillSymbol = [[AGSSimpleFillSymbol alloc] initWithStyle:AGSSimpleFillSymbolStyleSolid color:[UIColor colorWithWhite:1 alpha:0.3] outline:simpleLineSymbol];
self.searchGraphic = [[AGSGraphic alloc] initWithGeometry:project.geometry symbol:fillSymbol attributes:@{@”name”:project.projectname,@”address”:project.projectid}];
[self.graphicsOverlay.graphics addObject:self.searchGraphic];
AGSViewpoint *viewpoint = [self getGeometryViewpoint:project.geometry];
[self.mapView setViewpoint:viewpoint completion:nil];
设置显示范围:
AGSEnvelope *geoExtent = geometry.extent;
double width = geoExtent.width * 2 + 390;
double height = geoExtent.height * 2;
double centerX = geoExtent.center.x - 125;
AGSPoint *center = [[AGSPoint alloc] initWithX:centerX y:geoExtent.center.y spatialReference:geoExtent.spatialReference];
AGSEnvelope *mapExtent = [[AGSEnvelope alloc] initWithCenter:center width:width height:height];
return [[AGSViewpoint alloc] initWithTargetExtent:mapExtent];
距离计算
double distance =[AGSGeometryEngine geodeticLengthOfGeometry:self.sketchEditor.geometry lengthUnit:AGSLinearUnit.meters curveType:AGSGeodeticCurveTypeGeodesic];
面积计算
double area = [AGSGeometryEngine geodeticAreaOfGeometry:self.sketchEditor.geometry areaUnit:AGSAreaUnit.squareKilometers curveType:AGSGeodeticCurveTypeGeodesic];
设置中心点
AGSPoint *center = [[AGSPoint alloc] initWithX:114.349384 y:30.574897 spatialReference:[AGSSpatialReference WGS84]];
[self.mapView1 setViewpointCenter:center scale:400000 completion:nil];
禁用旋转
self.mapView.interactionOptions.rotateEnabled = NO;
监听视野变化
self.mapView.viewpointChangedHandler = ^{
dispatch_async(dispatch_get_main_queue(), ^{
if (!weakSelf.rightView.isHidden && weakSelf.mapView == weakSelf.touchMapView) {
[weakSelf.mapView1 setViewpointGeometry:weakSelf.mapView.visibleArea completion:nil];
}
});
};
删除logo
for (UIView *subview in self.mapView.subviews){
if ([subview isKindOfClass:NSClassFromString(@”AGSLogoView”)]) {
subview.hidden = YES;
}
}