这是indexloc提供的服务,不要输入任何密码
Skip to content

Add shape.name to tm_shape #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 21, 2017
Merged

Add shape.name to tm_shape #129

merged 1 commit into from
Aug 21, 2017

Conversation

johnaclouse
Copy link
Contributor

Hi Martijn,

First off, thank you so much for such an excellent package. I had been trying to migrate from ggplot to leaflet, but there was so much missing functionality, that I had begun to loose hope in being able to reproduce an interactive version of my work. The tmap package has been a great boon.

I wanted to plot several attributes on the same map and allow the user to use the legend to turn on and off layers as appropriate. An attribute to override the name of the shp object seems to solve the problem nicely. I must apologize in advance; I've never submitted a pull request before, so I could be going about this the entirely wrong way.

Cheers,
John

Code proposed (not sure my pull request will work)

tm_shape <- function(shp,
shape.name = NULL,
is.master = NA,
projection=NULL,
bbox = NULL,
unit = getOption("tmap.unit"),
simplify = 1,
line.center.type = c("segment", "midpoint"),
...) {
shp_name <- ifelse(is.null(shape.name) == TRUE, deparse(substitute(shp))[1], shape.name)
g <- list(tm_shape=c(as.list(environment()), list(...)))
class(g) <- "tmap"
g
}

@mtennekes mtennekes merged commit e5cadd0 into r-tmap:master Aug 21, 2017
mtennekes added a commit that referenced this pull request Aug 21, 2017
@mtennekes
Copy link
Member

mtennekes commented Aug 21, 2017

Hi John,

Great addition! I just made some small changes, e.g. changed "shape.name" to just "name" (as it is an argument of tm_shape).

I try to apply the policy to include all people who made commits to the tmap code (no matter how small) in the authors list (as contributors). You you please enter your email address to https://github.com/mtennekes/tmap/blob/master/DESCRIPTION (or remove the line if you prefer to be anonymous)?

@johnaclouse
Copy link
Contributor Author

johnaclouse commented Aug 29, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants