Select to view content in your preferred language

AGSSketchGraphicsLayer - line/polygon symbols not showing

2855
2
12-04-2014 05:42 AM
ØyvindIdland
New Contributor III

I am working on an app that's using AGSSketchGraphicsLayer for editing.

When editing starts, the vertices, midpoints, and selected vertex shows and responds. However, there are no line drawn between the vertices.

I also tried creating my own composite symbol for the mainSymbol:

    _renderSymbols = [AGSCompositeSymbol compositeSymbol];

    AGSSimpleLineSymbol* lineSymbol = [[AGSSimpleLineSymbol alloc] init];

    lineSymbol.color= [UIColor redColor];

    lineSymbol.width = 2;

    lineSymbol.style = AGSSimpleLineSymbolStyleSolid;

    [_renderSymbols addSymbol:lineSymbol];

    AGSSimpleFillSymbol* fillSymbol = [[AGSSimpleFillSymbol alloc] init];

    fillSymbol.color = [UIColor colorWithRed:0.0 green:1.0 blue:0 alpha:.4] ;

    [_renderSymbols addSymbol:fillSymbol];

    _featureSketchLayer = [[AGSSketchGraphicsLayer alloc]initWithGeometry:nil];

    _featureSketchLayer.mainSymbol = _renderSymbols;

    [self.mapView addMapLayer:_featureSketchLayer withName:@"Feature sketch layer"];

Still, it looks the same, with only vertices/midpoints rendered.

I am using Runtime for iOS v.10.2.4.

0 Kudos
2 Replies
SuganyaBaskaran1
Esri Contributor

Can you verify a few things?

1. Using popups to edit existing feature, can you check if popupsContainer:readyToEditGraphicGeometry:forPopup: is implemented and has the following code

self.sketchLayer.geometry = geometry;

2. Using popups to create new feature: Implement popupsContainer:wantsNewMutableGeometryForPopup: and return a correct geometry based on the layer to be edited and its spatial reference.

3. When you load custom symbols, verify mainSymbol is not nil during execution.

4. Instead of this,

_featureSketchLayer = [[AGSSketchGraphicsLayer alloc]initWithGeometry:nil];

you may initialize the sketch layer with a geometry type of your layer, and the spatial reference of your map. The map should be loaded at this point, so mapViewDidLoad: method is a good place to test.

self.polyline = [[AGSMutablePoint alloc] initWithSpatialReference:self.mapView.spatialReference];

self.sketchGraphicsLayer = [[AGSSketchGraphicsLayer alloc] initWithGeometry:self.point];

Alternatively, you can initialize the sketch layer right in the beginning, and when you start sketching assign an empty geometry (for new features), or the current feature’s geometry (for existing features).

You may also check out a related sample here. If none works, can you share a simple project that reproduces the issue?

Thanks,

Suganya

0 Kudos
ØyvindIdland
New Contributor III

Hi Suganya, thanks for the suggestions.

First, this is case is when creating new features (using a template). Also, the geometry do exist, and has to so since the vertices and midpoint-grips are shown correctly.

The mainSymbol is indeed instantiated when I create the layer:

(lldb) po self.featureSketchLayer.mainSymbol.symbols

<__NSArrayI 0x7b180560>(

<AGSSimpleFillSymbol: 0x7ae283c0>,

<AGSSimpleLineSymbol: 0x7ae19880>

)

I also tried supplying a dummy feature with the actual geometry type + same spatial reference as in the map in initWithGeometry, with no effect.

For now, I made a workaround that seems to work fairly well: I created another AGSGraphicLayer, with one Graphic. I then listen to AGSSketchGraphicsLayerGeometryDidChangeNotification, and perform the following:

- (void)respondToGeomChanged: (NSNotification*) notification {

    self.drawingGraphic.geometry = self.featureSketchLayer.geometry;

}

This will probably work for now. I will try to make a small reproducible project as soon as I get time for it

- Oyvind

0 Kudos