2

I want to plot ships and its direction on the map using R Leaflet.

I tried to represent a ship as a circle and its direction with a line from the center as in the following picture.

enter image description here

The problem is that when zooming out the direction is lost (see picture below) because the circles maintain their size regardless of zoom but the lines do not.

enter image description here

For the circles I am using addCircleMarkers() function. For the lines I am using addPolylines(). addCircleMarkers() maintains its size regardless of zoom level but addPolylines() does not.

Are there any alternatives I could use to represent direction?. I think about using an icon and rotating it using the addAwesomeMarkers() function. The problem with this approach is that it also adds a marker but I just want the icon.

The ideal solution would be to have a line (or arrow) with size not dependent on zoom level or to be able to use an icon and rotate it.

Here is a related question for rotating an icon but seems hacky and not sure if it can be extended to more icons (the example uses 1) with different angles each.

  • any joy on this problem? I am looking to do exactly what you want to do. – Dhiraj May 21 '18 at 16:01
  • I think that addAwesomeMarkers() is not that bad. For example you can combine it with an "arrow-up" icon and was satisfactory for me. Otherwise, can try to use iconList() function (you find an example in this documentation), defining a series of rotated images/icons corresponding to several rotation classes. – Valentin Jan 21 at 9:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.