Skip to content
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

In interactive mode, id doesn't show in v4 #851

Open
olivroy opened this issue Mar 28, 2024 · 10 comments
Open

In interactive mode, id doesn't show in v4 #851

olivroy opened this issue Mar 28, 2024 · 10 comments
Labels
view View mode issues

Comments

@olivroy
Copy link
Contributor

olivroy commented Mar 28, 2024

Hi @mtennekes ,

I started looking into transitioning to v4 in my previous code. I think I ran into a bug.

  • Missing id hovering.
  • The popup doesn't show id as bold on top of the popup either
  • Also the layers is "uncovered" by default. Before, it was hidden
devtools::load_all()
tmap_mode("view")
data("NLD_muni") # only needed for v3
NLD_muni |> 
  tm_shape() +
  tm_polygons(
    id = "code"
  )

v4 : nothing when hovering and no title on top of the popup

image

v3.3-4 : id showing when hovering + shows as bold on top of the popup

image

Thanks

other issues

# search query for OpenStreetMap nominatim
tmap_mode("view")
qtm("Amsterdam")
#> Error in tm_view(bbox = "Amsterdam")
#>   Unused argument (bbox = "Amsterdam")

Does not focus on China

qtm(metro, bbox = "China")

v4 doesn`t respect borders = NULL

qtm(World, borders = NULL) + 
qtm(metro, symbols.size = "pop2010", 
    symbols.title.size= "Metropolitan Areas", 
    symbols.id= "name",
    format = "World")

In v3
image

In v4, currently, has borders, size is not passed correctly.
image

I also like that the legend background in view was a bit transparent, could this be added back?

@mtennekes
Copy link
Member

This is discussed earlier, but great to bring it up again because this is not settled yet.

#749: suggestion to disable hovering by default
#764: further discussion of possibilities

Current status: each layer has four related arguments:

  • hover Also used for the popup title
  • id Only used for interactive features, e.g. shiny (via layerId)
  • popup.vars
  • popup.format

What do you think? Suggestions more than welcome.

NLD_muni |> 
	tm_shape() +
	tm_polygons(
		hover = "name",
		popup.vars = c("code", "name", "population")
		
	)

To do's: layer selection collapse (default) and fix bbox focus

I've made the legend background deliberately solid, for two reasons: to make it consistent with plot mode, and to make sure that what is shown in the legend (symbols) are exactly the same as the features in the map they represent. However, in some cases I also prefer a bit transparency. What are your thoughts on this @Nowosad ?

@mtennekes
Copy link
Member

qtm improved, please check @olivroy
still a to do: redirect ... arguments such as symbols.title.size

@olivroy
Copy link
Contributor Author

olivroy commented Apr 11, 2024

I would agree that hovering and id should not be enabled by default.

However, if id is supplied, hocering could be enabled, and also having the bold title on top of the popup

@mtennekes
Copy link
Member

What do you think of the different variations: id, hover, label, ... ? Currently we only use id for layer reference, but in v3 we also used it for labeling.

The difficulty is the fact that we often want to specify a few things at once (e.g. hovering label, popup title, and layer reference id), but in some cases we explicitly want to separate things (e.g. country name for labeling and iso a3 code for reference ids).

@olivroy
Copy link
Contributor Author

olivroy commented Apr 11, 2024

good idea!

# defaults
id = "" # not shown by default
popup.title = id # id by default
hover = FALSE # by default if id is not supplied

what do you think?

In v3 layer id was via name if I remember correctly..

@Nowosad
Copy link
Member

Nowosad commented Apr 11, 2024

@mtennekes have you consider having just one argument that accepts a function (e.g., tm_popup())?

@olivroy olivroy added the view View mode issues label Apr 11, 2024
@mtennekes
Copy link
Member

mtennekes commented Apr 11, 2024

So bringing this together we have:

tm_shape(World) + 
tm_polygons(fill = "economy",
  id = "iso_a3",
  popup = tm_popup(title = "name", vars = c("economy", "income_grp")),
  hover = FALSE)

Defaults:

  • id = ""
  • popup = tm_popup(title = id, vars = TRUE) where TRUE means all variables.
    In v3 this was different: vars consisted of all data variables that were visualised, and all variables if no data was visualised. What do you prefer?
  • hover = FALSE, also when id != ""?

@tim-salabim
Copy link

Just in case people forgot, there's leafpop::popupTable which does pretty much all of this, apart from the popup title... It also allows to supply a cssName which you could use to style the popups (like we do in mapview). Let me know if there is interest in expanding functionality to provide what is needed for tmap.

@tim-salabim
Copy link

Am I correct in assuming that tm_popup() does not exist (yet)? I can't seem to find it in the repo

@Nowosad
Copy link
Member

Nowosad commented Apr 11, 2024

@tim-salabim yep -- it is still an idea

@mtennekes mtennekes mentioned this issue Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
view View mode issues
Projects
None yet
Development

No branches or pull requests

4 participants