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

Enable hover options for vector sources in MapLibre #67

Open
walkerke opened this issue Jan 15, 2025 · 2 comments
Open

Enable hover options for vector sources in MapLibre #67

walkerke opened this issue Jan 15, 2025 · 2 comments

Comments

@walkerke
Copy link
Owner

Now that we have pmtiles support in MapLibre, #36 is relevant (the second part of the issue) as I only enabled hover options for tiles coming from Mapbox.

I tried swapping in the code directly from mapboxgl.js to maplibregl.js and it didn't work out of the box, so I'll need to look into this further.

@cboettig
Copy link
Contributor

@walkerke can you expand upon what is missing here? Your tooltip hovers seem to work just fine?

library(mapgl)
pmtiles <- "https://data.source.coop/cboettig/us-boundaries/mappinginequality.pmtiles"


m <-
  maplibre(center=c(-72.9, 41.3), zoom=10, height="400") |>
  add_vector_source("mappinginequality_source",
                    url = paste0("pmtiles://", pmtiles)
  ) |>
  add_fill_layer(
    id = "mappinginequality_layer",
    source = "mappinginequality_source",
    source_layer = "mappinginequality",
    tooltip = "grade",
    filter = list("==", list("get", "city"), "New Haven"),
    fill_color = list("get", "fill")
  )

m

of course with any remote source your clever approach of creating a new html-styled column on-the-fly is not as viable, so it might be nice to have another option for multi-column and styled tooltip / mouse-over effects?

@walkerke
Copy link
Owner Author

here's an example using Mapbox:

https://walker-data.com/mapboxapi/articles/dynamic-maps.html#styling-vector-tiles-with-mapbox-gl-js-and-mapgl

It's the hover_options argument that isn't working in MapLibre for vector sources, as it needs to target a source layer which it isn't currently doing.

Also - I agree about improving the popup / tooltip generation!

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

No branches or pull requests

2 participants