This page was created on October 27, 2026 as the peer-graded assignment for Developing Data Products (Week 2). It shows an interactive map, built with the Leaflet R package, of places worth visiting around Manipal Institute of Technology and the coastal town of Udupi, Karnataka.
Try these on the map:
# 1. The data: name, category, coordinates and a short description
places <- data.frame(
name = c("Manipal Institute of Technology", "Kasturba Medical College",
"Manipal Lake", "End Point", "Hasta Shilpa Heritage Village",
"Sri Krishna Matha, Udupi", "Malpe Beach", "St. Mary's Island",
"Kaup Beach & Lighthouse"),
category = c("Campus", "Campus", "Nature", "Nature", "Culture",
"Culture", "Beach", "Beach", "Beach"),
lat = c(13.3525, 13.3537, 13.3575, 13.3436, 13.3480,
13.3409, 13.3510, 13.3750, 13.2240),
lng = c(74.7928, 74.7862, 74.7880, 74.8003, 74.7843,
74.7524, 74.7031, 74.6740, 74.7454),
info = c("Engineering campus of MAHE, founded in 1957.",
"One of India's oldest private medical colleges.",
"Popular walking and jogging spot in the heart of Manipal.",
"Hilltop viewpoint over the Swarna river - best at sunset.",
"Restored traditional houses from across South India.",
"13th-century temple founded by Sri Madhvacharya.",
"Busy beach and fishing harbour; boats leave for St. Mary's Island.",
"Islands of hexagonal basalt columns, about 88 million years old.",
"Quiet beach with a 1901 lighthouse you can climb."),
stringsAsFactors = FALSE
)
# Popup text (HTML) shown when a marker is clicked
places$popup <- paste0("<b>", places$name, "</b><br>",
"<i>", places$category, "</i><br>",
places$info)
# 2. One colour per category
categories <- c("Campus", "Nature", "Culture", "Beach")
pal <- colorFactor(c("#2c7fb8", "#31a354", "#d95f0e", "#c51b8a"),
levels = categories)
# 3. Base map with three switchable background styles
m <- leaflet(places) %>%
addTiles(group = "Street") %>%
addProviderTiles(providers$Esri.WorldImagery, group = "Satellite") %>%
addProviderTiles(providers$OpenTopoMap, group = "Terrain")
# 4. Add each category as its own layer so it can be toggled on/off
for (cat in categories) {
m <- m %>%
addCircleMarkers(data = places[places$category == cat, ],
lng = ~lng, lat = ~lat,
radius = 9, color = "white", weight = 2,
fillColor = ~pal(category), fillOpacity = 0.9,
popup = ~popup, label = ~name,
group = cat)
}
# 5. A suggested one-day route: campus -> End Point -> temple -> beach -> island
route <- places[match(c("Manipal Institute of Technology", "End Point",
"Sri Krishna Matha, Udupi", "Malpe Beach",
"St. Mary's Island"), places$name), ]
m %>%
addPolylines(lng = route$lng, lat = route$lat,
color = "#444444", weight = 3, dashArray = "8, 8",
group = "One-day route") %>%
addLegend("bottomright", pal = pal, values = categories,
title = "Category", opacity = 1) %>%
addLayersControl(baseGroups = c("Street", "Satellite", "Terrain"),
overlayGroups = c(categories, "One-day route"),
options = layersControlOptions(collapsed = FALSE)) %>%
addMiniMap(toggleDisplay = TRUE, minimized = TRUE) %>%
addMeasure(position = "bottomleft", primaryLengthUnit = "kilometers") %>%
addScaleBar(position = "bottomleft") %>%
addEasyButton(easyButton(icon = "fa-home", title = "Reset view",
onClick = JS("function(btn, map){ map.setView([13.33, 74.75], 11); }"))) %>%
setView(lng = 74.75, lat = 13.33, zoom = 11)knitr::kable(places[, c("name", "category", "lat", "lng")],
col.names = c("Place", "Category", "Latitude", "Longitude"),
digits = 4)| Place | Category | Latitude | Longitude |
|---|---|---|---|
| Manipal Institute of Technology | Campus | 13.3525 | 74.7928 |
| Kasturba Medical College | Campus | 13.3537 | 74.7862 |
| Manipal Lake | Nature | 13.3575 | 74.7880 |
| End Point | Nature | 13.3436 | 74.8003 |
| Hasta Shilpa Heritage Village | Culture | 13.3480 | 74.7843 |
| Sri Krishna Matha, Udupi | Culture | 13.3409 | 74.7524 |
| Malpe Beach | Beach | 13.3510 | 74.7031 |
| St. Mary’s Island | Beach | 13.3750 | 74.6740 |
| Kaup Beach & Lighthouse | Beach | 13.2240 | 74.7454 |
Map data © OpenStreetMap contributors, OpenTopoMap and Esri. Coordinates are approximate.