Adjust RMPath alpha after adding it as sublayer

49 views
Skip to first unread message

zwitt.t...@gmail.com

unread,
Jun 3, 2013, 12:44:12 PM6/3/13
to route-...@googlegroups.com
Hi, does anyone know if its possible to change the alpha of a RMPath after its been added via [[mapView.contents overlay] addSublayer:xxx? I can't seem to access it via the methods I would expect (I believe it must be possible but perhaps I have created the path in the wrong way to adjust it later). My aim is to use a settings page to be able to adjust the opacity of the stroke well after everything has been set up.

Thanks.

shenstech

unread,
Jun 3, 2013, 1:15:13 PM6/3/13
to route-me
Do you keep track of your paths? One of my apps has the ability to
toggle geoAreas that I build out of RMPath objects, which I just keep
in an NSMutableArray called geoPaths. When I want to toggle them, I
simply iterate through the array and change the hidden value:

for(RMPath *path in geoPaths) {
[path setHidden:hiddenBool];
}

I don't see any reason you couldn't do the same, except replacing
setHidden with setLineColor and setFillColor, where the color you set
them to keeps the same RGB values with adjusted alphas. As long as
you don't have obscene amounts of paths this should run fairly
smoothly.

zwitt.t...@gmail.com

unread,
Jun 3, 2013, 4:28:25 PM6/3/13
to route-...@googlegroups.com
Thanks a lot, that works perfectly to be able to access the original RMPath. One other thing I am wondering is whether my method of changing the alpha is right or is there a more efficient way. I am currently doing this when I want to update the alpha:

routeColor = [[UIColor alloc] initWithRed:(255.0 /255) green:(0.0 /255) blue:(0.0 /255) alpha:0.5];

[myRMPath setLineColor:(UIColor *)routeColor];


Do you know if theres a way to do this without alloc'ing? IE directly modify the RMPath attribute directly? From what I can tell I have to make a new one each time because in the setLineColor method the old lineColor is discarded but this seems inefficient. If I implement a slider to adjust line alpha I wonder if it would be smooth.

The other problem I have is I don't seem to be able to remove old paths, if the user changes the path they want to display, no matter what I do my mapView.contents overlay count keeps rising. I tried removeFromSuperlayer, release and a couple of other things but nothing works. Do you have any idea how to remove the old layer?

Thanks

Stephan Hennion

unread,
Jun 4, 2013, 9:14:36 AM6/4/13
to route-...@googlegroups.com
Well, UIColor has an initialization method UIColor *myColor = [UIColor colorWithRed:0.0f green:0.0f green:0.0 blue:0.0f alpha:0.0f];. I don't think you can set specific components (RGBA) of UIColor after initialization, but honestly it's not like that colorWithRed method is an expensive operation, so you're not hurting anything with your current method. Unless someone else can chime in otherwise I'd say it's a safe bet.
--
You received this message because you are subscribed to the Google Groups "route-me" group.
To unsubscribe from this group and stop receiving emails from it, send an email to route-me-map...@googlegroups.com.
To post to this group, send email to route-...@googlegroups.com.
Visit this group at http://groups.google.com/group/route-me-map?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply all
Reply to author
Forward
0 new messages