Skip to main content

Custom style URLs and relative resources

Common setStyle accepts HTTP(S) or validated hierarchical custom URLs; customStyleResourceURLs is true. Full replacement, inline styles/null and diff:false retain their semantics; diff:true remains unavailable. Capability describes core and public bindings; the host must deliver each URL.

map.setStyle('memory://assets/maps/style.json',{diff:false});
await map.sqs.flush();
// flush confirms writes. Wait for style.load/error for actual resources.

Relative TileJSON, tiles and sprite resources resolve against the real custom style URI. ../tiles.json becomes memory://assets/tiles.json, and TileJSON ./0/0/0.png uses that real base. Sprite JSON/PNG and query strings retain the original scheme. Requests keep Style/Source/Tile/SpriteJSON/SpriteImage types, generation and byte budgets.

Custom resource origin identity uses scheme://authority; different schemes, hosts and ports no longer collapse into one null origin. HTTP origin serialization and HTTP network adapters' HTTPS/loopback, private-address and redirect rules stay unchanged. Core custom URI support does not add protocols to HTTP downloaders. Browser hosts register addProtocol separately in the map realm and Worker; native C callers poll and deliver by the requested URI. Desktop custom downloaders and native JS callbacks remain pending.

Credential-free host-bearing URLs,4096-byte style entries and shared reserved-scheme validation apply. file/data/blob/ws are not custom style protocols. Lifecycle uses styledata/style.load; invalid addresses preserve the previous style. Transport failures and rollback retain the existing resource contract.

The identical seven-check script and complete HTML/Worker/handler page cover actual styles at two authorities, relative TileJSON/tiles, sprites, failure preservation and real red raster pixels. Run within the complete matching SDK directory. See shared plans,source URLs andstandalone images. Standalone setGlyphs, live/3D downloaders, native JS registration, mobile/iOS/devices and formal releases remain later work.