Outdooractive / route-me

Open source map library for iOS
Other
122 stars 400 forks source link

annotation takes shortcut when moved #99

Open lukasvd opened 12 years ago

lukasvd commented 12 years ago

Small question I hope. I have a setup that when you move your finger over a elevation-plot, an annotation (marker) is shown along the line of a shape annotation. I do this by constantly updating the coordinate (by means of delegate). when you move your finger to fast over the plot, the marker annotation takes shortcuts (in fluent lines though), bezier like it seams. Is this something that can be influenced? I would like the marker to follow the given coordinates.

cloay commented 11 years ago

You can implement RMMapViewDelegate and add some code as follows:

lukasvd commented 11 years ago

Thanks for the reply. I do use the proposed procedure. From the (core-)plot events are send to the map object which updates the location.coordinate accordingly. I do this in exact the same manner for mkmapview and there the plot annotation on the map follows the polyline nicely. I also tried updating the annotation.position only (could be more lightweight to process) but the same results. It seems like when there are too much updates on a annotation location (or position) not all intermediate points are processed and the curve is determined by the delta of the points that do get processed, hence the nice curves.

incanus commented 11 years ago

Have you considered something like hiding the actual annotation and just animating a lookalike until it is released again? I'm not sure I've ever tried anything like this before. From what I understanding, you basically want to drag an annotation along a visible track?

lukasvd commented 11 years ago

Yep, that's what I am doing. To clarify the setup a bit more. Half the screen is a coreplot graph which visualizes the elevation of a polyline, the other half of the screen is a map object (mkmapview or rmmapview) which shows the polyline. When you move your finger over the elevation graph there is a small image on the map (rmmarker annotation based on an image) that shows exactly where you are on the map (point on the polyline). This works nicely for mkmapview, did work as well for the original rout-me lib I worked with, but is working different with the Alpstein fork I use now. If the gesture movement on the plot is slow it also works just fine, if you go faster it skips intermediate points (locations). Or so it seems. So when there is movement i show the "specialized" annotation, and hide/release it afterwards.

incanus commented 11 years ago

I would recommend profiling the code to see what's taking up the time. Maybe it's something easy that could be pre-calculated like pixel-to-coordiante conversions or something like that.