Partner links

Building Interactive Maps with Leaflet

Leaflet JavaScript library logo

Leaflet is an JavaScript library for building interactive maps. RStudio released a package that allows us to build these maps in R!

You can do some really cool things in Leaflet, and I will demonstrate a few of those below. Leaflet is compatible with Shiny apps and R Markdown documents.

As mentioned on the RStudio page, the basic steps to create a Leaflet map are:

1. Create a map widget using leaflet()
2. Add layers to the map using addTiles(), addMarkers(), etc.
3. Print the map.

Okay, let’s get started. We will need the leaflet and magrittr packages for this.

Let’s create a basic map centered at San Francisco. First, we create a widget by calling leaflet(). Then, we add tiles to the map using addTiles(). By default, it uses Open Street Map tiles. If you would like to use other tiles, please refer here. We can set the desired longitude and latitude that we want the map to be centered at, and also set the zoom level using the setView() function. The addMarker() function allows us to add a marker at our desired location, with it’s own popup message!

Visit this web page to read the complete article.

Leaflet JavaScript library logo

Share:

Facebook
Twitter
Pinterest
LinkedIn

Partner links

Newsletter: Subscribe for updates

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

Get the latest

On social media

Security distros

Hacker
Linux distros for hacking and pentesting

Crypto mining OS

Bitcoin
Distros for mining bitcoin and other cryptocurrencies

Crypto hardware

MSI GeForce GTX 1070
Installing Nvidia GTX 1070 GPU drivers on Ubuntu

Disk guide

LVM
Beginner's guide to disks & disk partitions in Linux

Bash guide

Bash shell terminal
How to set the PATH variable in Bash
Categories
Archives
0
Hya, what do you think? Please comment.x
()
x