Skip to content

feat: add ScatterMap trace for the MapLibre map subplot#417

Open
jqnatividad wants to merge 5 commits into
plotly:mainfrom
dathere:feat/scatter-map-upstream
Open

feat: add ScatterMap trace for the MapLibre map subplot#417
jqnatividad wants to merge 5 commits into
plotly:mainfrom
dathere:feat/scatter-map-upstream

Conversation

@jqnatividad

Copy link
Copy Markdown
Contributor

Summary

plotly.rs has ChoroplethMap and DensityMap (#416) for the modern MapLibre map subplot (layout.map), but no scatter/marker trace for it. plotly.js provides scattermap as the MapLibre-based successor to the (Mapbox-based, now deprecated) scattermapbox. This PR adds a matching ScatterMap Rust trace.

⚠️ Stacked on #416

ScatterMap is drawn on the MapLibre map subplot introduced in #410 (via LayoutMap/MapStyle), so this PR is stacked on top of #416#410 and should be reviewed/merged after them. Until they merge, the diff here also shows their commits; once they land in main, this diff reduces to just the ScatterMap addition. (Depends on #410; branched off #416 for a linear map-trace stack.)

What changed

New ScatterMap<Lat, Lon> trace mirroring ScatterMapbox field-for-field, but drawn on layout.map and emitting "type": "scattermap":

  • Data/marks: lat, lon, mode, marker, line, opacity, connectgaps
  • Fill/selection: local Fill enum (none/toself), Selection/SelectionMarker (selected/unselected/selectedpoints), fill, fillcolor
  • Text: text, textposition, texttemplate, texttemplatefallback, textfont
  • Hover: text, hovertext, hoverinfo, hovertemplate, hovertemplatefallback, hoverlabel
  • Legend/misc: name, visible, showlegend, legendrank, legendgroup, legendgrouptitle, subplot (references layout.map), below, ids, meta, customdata, uirevision

Registration: a ScatterMap variant on PlotType (serializes to "scattermap"), plus module/type re-exports in traces/mod.rs and lib.rs. Includes serialize_scatter_map/serialize_fill/serialize_selection unit tests and a doctest.

Testing

  • cargo test -p plotlyserialize_scatter_map and its doctest pass.
  • cargo clippy --features all -- -D warnings -A deprecated — clean.
  • cargo +nightly fmt --all -- --check — clean.

🤖 Generated with Claude Code

jqnatividad and others added 5 commits July 1, 2026 06:48
Add choropleth map support (addresses plotly#408):

- `Choropleth<Loc, Z>` on the existing `geo` subplot, with a `LocationMode`
  enum (ISO-3 / USA-states / country names / geojson-id), a dedicated
  `choropleth::Marker`, selection support, z-bounds, and the shared
  `ColorScale`/`ColorBar` machinery. `geojson` accepts a URL string or an
  inline GeoJSON object.
- `ChoroplethMap<Loc, Z>`, the plotly.js 3.x `choroplethmap` trace on the
  MapLibre `map` subplot (GeoJSON-only).
- New MapLibre `map` subplot via `LayoutMap` + `MapStyle` + `MapBounds`.
- `LayoutGeo` additions: `fitbounds` (`GeoFitBounds`), `resolution`
  (`GeoResolution`, 1:110M/1:50M base-layer detail), and `bgcolor`.
- `PlotType::Choropleth`/`ChoroplethMap` variants, re-exports, serialization
  tests, doctests, runnable `examples/maps` examples, and a Maps book recipe.

Attribute names/types follow the plotly.js v3.6.0 plot-schema.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The embedded choropleth example calls GeoResolution::OneOverFiftyMillion,
but the shared import block omitted GeoResolution, so copying the documented
imports alongside the example would not compile.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add the modern MapLibre-based `densitymap` trace type, the density
counterpart to `ChoroplethMap`. It draws a weighted kernel-density
heatmap from lat/lon points (optional per-point weight z) onto the
`layout.map` subplot, with full color-scale (colorscale, colorbar,
showscale, reversescale, autocolorscale, coloraxis, zmin/zmax/zmid)
and hover (text, hovertext, hoverinfo, hovertemplate, hoverlabel,
customdata) support. Unlike ChoroplethMap it has no marker/selection.

Registers the trace: DensityMap variant on PlotType (serializes to
"densitymap"), module + type re-exports in traces/mod.rs and lib.rs.
Includes a serialize_density_map unit test and a doctest.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add `ScatterMap`, the MapLibre-based counterpart to `ScatterMapbox`, drawn
on the `layout.map` subplot (`LayoutMap`/`MapStyle`). It mirrors
`ScatterMapbox` field-for-field — markers/lines, `Fill`/`Selection`, and the
full hover set (text/hovertext/hoverinfo/hovertemplate/customdata/hoverlabel)
— but emits `"type": "scattermap"` and references `layout.map`.

Add a `PlotType::ScatterMap` variant, re-export `ScatterMap` and the
`scatter_map` module, and add a `serialize_scatter_map` unit test plus a doc
example.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant