Skip to content

feat: add MapLibre GL + PMTiles basemap support (dual-mode CRS)#126

Open
fank wants to merge 7 commits intomainfrom
feat/maplibre-pmtiles
Open

feat: add MapLibre GL + PMTiles basemap support (dual-mode CRS)#126
fank wants to merge 7 commits intomainfrom
feat/maplibre-pmtiles

Conversation

@fank
Copy link
Member

@fank fank commented Feb 4, 2026

Summary

  • Adds optional MapLibre GL basemap rendering under Leaflet with PMTiles protocol support
  • Implements dual-mode CRS: legacy L.CRS.OCAP (pixel-based) for existing raster tiles, and L.CRS.EPSG3857 (geographic) for MapLibre basemaps
  • Activated per-world by adding maplibreStyle URL to a map's map.json — no existing maps are affected
image image image image

Changes

File Changes
static/index.html Added MapLibre GL v4.7.1, leaflet-maplibre-gl v0.0.22, pmtiles v4.4.0 (CDN)
static/scripts/ocap.js Dual-mode CRS, armaToLatLng(), getMapImageBounds(), MapLibre layer, raster tile gating
static/leaflet/L.Layer.Grid.js Grid coordinate conversion + zoom thresholds for EPSG:3857

How it works

  • armaToLatLng() is the single gate for all coordinate conversions (20+ call sites, 5 files). Making it dual-mode means all entity, marker, event, and grid code works in both CRS modes without changes.
  • Arma meters map to degrees at the equator via METERS_PER_DEGREE = 111320. Mercator distortion is negligible for sub-degree map extents (~0.1% error). No proj4 dependency needed.
  • PMTiles protocol registered idempotently so style.json can use pmtiles:// URLs.

How to activate for a map

Add maplibreStyle to the world's map.json:

{
  "maplibreStyle": "https://maps.ocap2.com/styles/altis/style.json"
}

Remaining infrastructure (not in this PR)

  • Create PMTiles from existing raster tiles
  • Create style.json files per world
  • Host pmtiles + style.json on maps.ocap2.com (needs HTTP range request support)
  • Browser testing with actual MapLibre basemaps

Test plan

  • Verify existing raster tile maps still work (no maplibreStyle = legacy mode)
  • Verify grid overlay renders correctly in both modes
  • Test with a maplibreStyle URL pointing to a valid style.json + PMTiles source
  • Verify entity positions, markers, and events render correctly in MapLibre mode

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