How do I subclass AGSGeometry and override CGPath used for drawing a polyline?

3837
3
Jump to solution
05-01-2015 04:35 PM
AkhilChoran_Balan
New Contributor

In my project I have a requirement to draw some arc shapes on maps as overlay. I tried with "AGSPolyline" but it draws only straight lines connecting to points. I was able to do this feature in MapKit by subclassing "MKOverlayPathRenderer" and by overriding "createPath". I would like to do the same but looks like there is no path property available on AGSGeometry. Please let me know how I can achieve this using ESRI iOS map.

0 Kudos
1 Solution

Accepted Solutions
GagandeepSingh
Occasional Contributor II

You may subclass the AGSDynamicLayer to achieve this. A sample is available here.

In this sample we are using to generate an image for the envelope. In your case, you may use CGPath to render an arc and draw it into an image using CGContext. Once you have the image you just need to set the image using - setImageData:forEnvelope: the method, inside the - requestImageWithWidth:height:envelope:timeExtent: method override.

Let me know if this helps.

Gagan

View solution in original post

3 Replies
GagandeepSingh
Occasional Contributor II

You may subclass the AGSDynamicLayer to achieve this. A sample is available here.

In this sample we are using to generate an image for the envelope. In your case, you may use CGPath to render an arc and draw it into an image using CGContext. Once you have the image you just need to set the image using - setImageData:forEnvelope: the method, inside the - requestImageWithWidth:height:envelope:timeExtent: method override.

Let me know if this helps.

Gagan

AkhilChoran_Balan
New Contributor

Thanks for the answer. I will try it out. Feels like a work around since we can draw polyline and polygon without using dynamic layer. Ability to subclass AGSGeometry and modify CGPath property would have been perfect.

0 Kudos
GagandeepSingh
Occasional Contributor II

We don't use CGPath for drawing our polylines or polygons.

0 Kudos