Skip to content

Commit

Permalink
First attempt at #13
Browse files Browse the repository at this point in the history
  • Loading branch information
SamanthaToet committed Nov 21, 2019
1 parent 72e1fe5 commit a135dac
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
13 changes: 9 additions & 4 deletions R/print.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
#' Print a leaflet map of results
#' Print a Leaflet map of results
#'
#' @param x Yelp business table created from search query.
#' @param ... Optional arguments to print.
#' @param view Interactive leaflet map
#' @param view Interactive leaflet map.
#'
#' @return Returns a table of relevant businesses in the console and prints an interactive Leaflet map in the Viewer tab. Relevant businesses are marked.
#'
#' @export
print.business_tbl <- function(x, ..., view = interactive()) {
print.business_tbl <- function(x, ..., view = interactive(), show_map = getOption("yelpr.show_map")) {
popup <- paste0("<p style=\"text-align:center;\"><strong>", x$name, "</strong>", "<br>", "Rating: ", x$rating, "<br>", x$address, "</p>")
#popup <- htmltools::tags$p(x$name) %>% as.character() - try with for loop
#TODO: popup <- htmltools::tags$p(x$name) %>% as.character() - try with for loop

if (isTRUE(show_map) || is.null(show_map)) {
x %>% leaflet::leaflet() %>%
leaflet::addProviderTiles(
provider = "Stamen.TonerLite",
Expand All @@ -16,4 +20,5 @@ print.business_tbl <- function(x, ..., view = interactive()) {
leaflet::addMarkers(lng = x$lon, lat = x$lat, popup = popup) %>%
print(browse = view, ...)
NextMethod()
}
}
12 changes: 8 additions & 4 deletions man/print.business_tbl.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a135dac

Please sign in to comment.