On the trailer, at the dock, or on the water: they all work and at times any one of them is best.
You need a dozen feet or so clear behind the boat when you raise the mast on the trailer. If you have the room and don't have anything overhead that's going to be the easiest way to go. The boat will be fairly motionless and if you drop a tool or a pin you can just pick it up off the ground. Shrouds and stays won't fall into the water (particularly salt water). This is my preferred method if the parking lot and the overhead stuff cooperates but in reality there are only a couple of spots in my usual territory I've found where it can be done. Sometimes the parking lot is too crowded, the drive (with the mast up) is too far, or there is just too much overhead stuff (like your ramp).
The next easiest is to launch the boat without the mast and then move to a dock. Tied to a dock you are almost as motionless as the trailer but you have to be very careful not to drop stuff. It has the added benefit of being able to step off the boat onto the dock and walk around if you choose to not climb over stuff on the cabin top. This is the way I do it about 99% of the time.
The hardest way is to raise the mast while you are anchored or drifting. It's just like doing it at the dock (except for the dock) but you have to be sure that you don't drop anything or fall in yourself. Wind, waves, and wakes can make it interesting but it is not hard once you get used to it. I've only needed to do this a couple of dozen times and (knock on wood) have not dropped anything or fallen overboard yet.
I was just about to post this and I remembered another variation. Launch the boat and then find a spot to beach it while you raise the mast. This works great in a lake but twice I've been careless (or too slow) and had the tide go out and leave me high and dry when doing this in the Gulf. I
think I've learned my lesson and I won't get stranded again.
