Skip to content

popupTable should drop geometry column by default for sf objects #26

@davidhodge931

Description

@davidhodge931

Currently it only specifies the geometry type for sf objects, which is not that useful or consistent with how it works for sp objects.

library(leaflet)
library(leafpop)

leaflet() %>%
  addTiles() %>%
  addCircleMarkers(data = breweries91,
                   popup = popupTable(breweries91))

breweries91 <- sf::st_as_sf(breweries91)

leaflet() %>%
  addTiles() %>%
  addCircleMarkers(data = breweries91,
                   popup = popupTable(breweries91))

A way to modify this might be that if it is an sf object, popupTable should relocate geometry to the last col and then default the zcol to be from cols 1 to the second to last col.

  popup_data <- data %>%
      dplyr::relocate(.data$geometry, .after = tidyselect::last_col()) 
  
  popup <- leafpop::popupTable(popup_data, zcol = 1:ncol(popup_data) - 1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions