Select to view content in your preferred language

AGSGraphicsLayer addGraphic: Too Slow

2889
1
03-04-2013 01:38 PM
by Anonymous User
Not applicable
Original User: iqubalhusain

I am trying to create an application which supports "drawing style" annotations. To do this I setup a touch delegate from the map view. Between the previous and next point I create a AGSGraphic and load it onto the graphics layer.

- (void) addPointToMapFrom:(AGSPoint *) pp to:(AGSPoint *) cp;
{
    //Create Simple for Polyline
    AGSSimpleLineSymbol *lineSymbol = [AGSSimpleLineSymbol simpleLineSymbol];
    lineSymbol.width = 3.0;
    lineSymbol.color = self.roleColor; 
    
    //Create Polyline Geometry
    AGSMutablePolyline *polyline = [[AGSMutablePolyline alloc] initWithSpatialReference:self.mapView.spatialReference];
    [polyline addPathToPolyline]; 
    [polyline addPointToPath:pp];
    [polyline addPointToPath:cp];
    
    //Add to graphics layer 
    AGSGraphic *graphic = [AGSGraphic graphicWithGeometry:polyline symbol:lineSymbol attributes:nil infoTemplateDelegate:nil];
    [self.graphicsLayer addGraphic:graphic];

   

}




Unfortunately this is extremely slow and there is noticeable lag as the user draws on the screen. Will I need to use a UIView to accomplish this?
0 Kudos
1 Reply
DanaMaher
Regular Contributor
...Unfortunately this is extremely slow and there is noticeable lag as the user draws on the screen. Will I need to use a UIView to accomplish this?


Is the user 1) tapping to add points to a piece of geometry, or 2) dragging their finger to sketch geometry?

If 1)

You probably want to use AGSSketchGraphicsLayer for creating geometry through this type user input. Have you looked at the code sample provided by ESRI?

If 2)

The ArcGIS Runtime SDK does not provide a good method for doing this. I have accomplished this workflow by adding a custom sketching layer on top of the AGSMapView that catches the users freehand gesture, draws it using core graphics, and then converts the sketched gesture into an AGSGraphic and draws that on the map. If this is your intended workflow, you are correct that you will have to draw on a UIView and translate that geometry into the map. The good news is that, with a little tweaking, you can create an incredibly smooth interface.
0 Kudos