Introduction

This webpage demonstrates an interactive map created using the Leaflet package in R.

The map displays selected cities around the world. Users can zoom, move around the map, and click markers to view location information.

Required Packages

Interactive Leaflet Map

The following map shows five major cities from different parts of the world.

# Create location dataset
locations <- data.frame(
  City = c(
    "Mumbai, India",
    "New York, USA",
    "London, UK",
    "Sydney, Australia",
    "Tokyo, Japan"
  ),
  
  Latitude = c(
    19.0760,
    40.7128,
    51.5074,
    -33.8688,
    35.6762
  ),
  
  Longitude = c(
    72.8777,
    -74.0060,
    -0.1278,
    151.2093,
    139.6503
  ),
  
  Description = c(
    "Financial capital of India",
    "Largest city in the United States",
    "Capital city of the United Kingdom",
    "Largest city in Australia",
    "Capital city of Japan"
  )
)

# Create interactive Leaflet map
leaflet(locations) %>%
  
  # Add map tiles
  addProviderTiles("CartoDB.Positron") %>%
  
  # Add markers
  addMarkers(
    lng = ~Longitude,
    lat = ~Latitude,
    popup = ~paste(
      "<b>", City, "</b><br>",
      Description
    )
  ) %>%
  
  # Add map controls
  addMiniMap() %>%
  addScaleBar()

About This Visualization

This interactive map was created using the Leaflet R package.

Features included:

This project demonstrates how geographic data can be visualized interactively using R Markdown and Leaflet.