Captain Hook: Mastering MapLibre’s hooks
summary
MapLibre exposes concrete extension points: community Contour plugin and inspect control let client code draw contours and inspect tile types; simple addControl returns an HTML element and stacks in corners; setTransformRequest rewrites every tile request (headers, HTTPS, credentials). A tiny ~10-line PR added addProtocol (custom protocols) enabling offline and h3 tiles for isra hiking map by returning byte arrays instead of network fetches. importScripts in workers injects JS into map workers but is fragile, undocumented and requires intimate worker internals.
AI-written summary · about
chapters (13)
- 0:00Introduction to MapLibre
- 3:14Why use hooks in MapLibre
- 4:38Plugins as simple hooks
- 6:00Adding controls to maps
- 7:26Transforming network requests
- 8:32Custom layer interface
- 10:00Custom protocol for offline tiles
- 13:56Using custom protocol
- 15:01Transform camera update hook
- 17:12Importing scripts in workers
- 22:43Summary of MapLibre hooks
- 23:06Sponsorship and maintenance
- 26:05Keeping hooks functional
