── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.4 ✔ readr 2.1.5
✔ forcats 1.0.0 ✔ stringr 1.5.1
✔ ggplot2 3.5.1 ✔ tibble 3.2.1
✔ lubridate 1.9.3 ✔ tidyr 1.3.1
✔ purrr 1.0.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(osmdata) # Fetch map data from osmdata.org
Data (c) OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright
library(tmap)
Breaking News: tmap 3.x is retiring. Please test v4, e.g. with
remotes::install_github('r-tmap/tmap')
library(sf)
Linking to GEOS 3.12.1, GDAL 3.8.4, PROJ 9.3.1; sf_use_s2() is TRUE
library(leaflet)
m <-leaflet() %>%# Add default OpenStreetMap map tilesaddTiles() %>%# Set view to be roughly centred on Bangalore CitysetView(lng =77.580643, lat =12.972442, zoom =12)m
m %>%addMarkers(lng =77.580643, lat =12.972442,popup ="The birthplace of Rvind")
m %>%addPopups(lng =77.580643,lat =12.972442,popup =paste("The birthplace of Rvind","<br>","Website: <a href = https://arvindvenkatadri.com>Arvind V's Website </a>","<br>" ),## Ensuring we cannot close the popup,## else we will not be able to find where it is,## since there is no Markeroptions =popupOptions(closeButton =FALSE) )
m %>%addMarkers(lng =77.580643,lat =12.972442,# Here is the Label defn.label ="The birthplace of Rvind",labelOptions =labelOptions(noHide =TRUE, # Label always visibletextOnly = F,textsize =20 ),# And here is the popup defn.popup =paste("PopUp Text: <a href = https://arvindvenkatadri.com>Arvind V's Website </a>","<br>" ) )
md_cities <-tibble(name =c("Baltimore", "Frederick", "Rockville", "Gaithersburg", "Bowie", "Hagerstown", "Annapolis", "College Park", "Salisbury", "Laurel"),pop =c(619493, 66169, 62334, 61045, 55232, 39890, 38880, 30587, 30484, 25346),lat =c(39.2920592, 39.4143921, 39.0840, 39.1434, 39.0068, 39.6418, 38.9784, 38.9897, 38.3607, 39.0993),lng =c(-76.6077852, -77.4204875, -77.1528, -77.2014, -76.7791, -77.7200, -76.4922, -76.9378, -75.5994, -76.8483))md_cities %>%leaflet() %>%addTiles()%>%# CircleMarkers, in blue# radius scales the Marker. Units are in Pixels!!# Here, radius is made proportional to `pop` numberaddCircleMarkers(radius =~ pop /1000, # Pixels!!color ="blue",stroke =FALSE, # no border for the Markersopacity =0.8 ) %>%# Circles, in redaddCircles(radius =5000, # Meters !!!stroke =TRUE,color ="yellow", # Stroke Colourweight =3, # Stroke Weightfill =TRUE,fillColor ="red", )
Assuming "lng" and "lat" are longitude and latitude, respectively
Assuming "lng" and "lat" are longitude and latitude, respectively
leaflet() %>%addTiles() %>%setView(lng =77.580643, lat =12.972442, zoom =6) %>%# arbitrary vector data for lat and lngaddPolygons(lng =c(73.5, 75.9, 76.1, 77.23, 79.8),lat =c(10.12, 11.04, 11.87, 12.04, 10.7) )
Rows: 340 Columns: 20
── Column specification ────────────────────────────────────────────────────────
Delimiter: ";"
chr (13): ident, type, name, continent, iso_country, iso_region, municipali...
dbl (4): id, elevation_ft, scheduled_service, score
num (2): lat, lon
dttm (1): last_updated
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.