RObservations #43 : Control Individual Label Positions In mapBliss With `_flex()` Functions

Introduction

After introducing the mapBliss package to the world, I was pleased to see that people started using it and were experimenting with making their own map art! On Github, the package got a few stars, some issues opened/closed and some improvements have been made since my last blog on the topic.

If you haven’t followed the journey of mapBliss so far check out these blogs:

  1. I reverse-engineered Atlas.co (well, some of it)

  2. Using the MapBox API with Leaflet

  3. Plotting Flight Paths on Leaflet Maps

  4. Packaging My Route Map Code! Introducing mapBliss.

While I thought the job was done for the package, sharing it with the world showed me what improvements and features can be added to it. In this blog I share a new line of functions available in mapBliss which allow for flexible label placement and future development features which I refer to as _flex() functions.

Using _flex() functions

The _flex() functions are the product of a Github issue which was posted noting that the original mapBliss functions only offer single direction label placement and universal label padding. It would be more useful to be able to control placement of each label. This feature enables users to have to have more options for label placement where a single direction for all labels would not be as aesthetically pleasing without deviating much from the original function syntax.

A great example of how the _flex() functions work is:

# devtools::install_github('benyamindsmith/mapBliss')

library(mapBliss)

plot_hybrid_route_flex(addresses=c("Amsterdam","Freddrikshavn","Kristiansand","Oslo"),
how=c("car","flight","car"),
weight=3,
colour="red",
label_position = c("left", "right","left","top"),
text_indent= c("1em","1em","1em","0.5em"),
mapBoxTemplate="https://stamen-tiles.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.jpg"
)

Thank you GTBoon72 for sharing this with me!

Conclusion

_flex() functions have now been added to the mapBliss! Be sure to install get the newest updates by running devtools::install_github("benyamindsmith/mapBliss) in your R console! If you find a bug or want a feature in this package feel free to open an issue. Let me know what you make!

Thank you for reading!

Want to see more of my content?

Be sure to subscribe and never miss an update!

Advertisement

2 thoughts on “RObservations #43 : Control Individual Label Positions In mapBliss With `_flex()` Functions

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s