1

Here is basically what I am trying to do:

1) Draw some routes on a map (Simple enough using MKPolyline and MKPolylineRenderer)
2) Label the routes (preferably repeat the label if there is room along the route)

  • Set Font of Text
  • Have Text follow the polyline's curves

I know the answer involves extending a class, but I'm not sure as to whether its MKPolyline or MKPolylineRenderer nor which method to handle it in.

darkrat
  • 673
  • 6
  • 14
  • If you don't want the text to change size as user zooms the map, you could simply put annotations (with views containing UILabels) along the route (you'll have to calc the coordinate and rotation). Otherwise, you should subclass MKOverlayPathRenderer. See comment on [this question](http://stackoverflow.com/questions/21050358/two-coloured-custom-line-on-mkpolylinerenderer). Also see [this](http://stackoverflow.com/questions/7825220/draw-text-in-circle-overlay?lq=1) and [this](http://stackoverflow.com/questions/10529217/is-there-away-to-add-text-using-paths-drawing) for ideas. –  Jan 22 '14 at 13:07
  • Did you ever come up with a nice solution for your problem? I am also trying to draw text along a path which works basically, but looks terrible if the path has a lot of spiky corners... – Georg Jan 03 '17 at 09:29
  • No, I handed the project off and never looked back :) – darkrat Jan 03 '17 at 20:28

1 Answers1

1

If your routes are relatively static, you may have better luck creating lines and labels with something like TileMill and pre-rendering alpha-transparent raster tiles to use with an MKTileOverlay. Aside from label placement along your lines, you will also have to deal with orientation changes, collisions between labels at junctions, varying zoom levels and changing the placement of the text during the changes, etc. You could instead leverage a label symbolizer that already does this sort of thing as in TileMill.

incanus
  • 5,100
  • 1
  • 13
  • 20