Skip to main content
A view is a named map: its own markers, camera limits, look, interactions and interface. A resource registers one, then opens the map with its id. Use a view for a map that is not the world map, such as a property viewer, a job board or a delivery selector. For adding markers to the standard map, use AddBlip instead. See Exports. Nothing is resolved when a view is registered. Everything — the configuration, the views it extends, the parameters it was opened with — is worked out when the map opens, so a reloaded config or an edited parent view reaches every view built on it without anyone registering anything again.

Contract

RegisterView answers whether the view was accepted. A view whose fields are of the wrong kind is refused, with the reason in the server console, rather than being carried into a map that then fails to open. The standard map is registered under the id world. Registering a view with that id replaces it.

Inputs

extends

A view listed in extends is applied first, and this view’s own fields are applied over it. Camera and look groups merge key by key, capabilities and interface fields are replaced one by one, marker layers are matched by their id, and the handlers of both run.
A chain that loops back on itself, or that names a view which is not registered, is reported and the missing level is skipped; the rest of the chain still applies.

focus

Where the map opens, instead of over the player.

Marker layers

blips is a list of layers drawn together, each with an id of its own. A view that mirrors the world map and adds markers of its own is two layers, not a choice between them. filter(ctx, blip) returns whether a world marker reaches the map at all. decorate(ctx, blip) returns marker information — the same fields as SetBlipMeta — layered over what the marker’s own resource set. The blip it is handed has handle, coords, type, sprite, color, alpha, display, shortRange, route, entity, name, icon and category. refresh is a number of milliseconds. Left out, a layer is built once per open. A layer is also rebuilt on demand with RefreshView, or from a handler with ctx.invalidate(layerId).
A view mirrors the world map once: a second world layer is refused.

Capabilities

Every capability is on unless the view turns it off. A capability is either a switch or a function asked again on every frame, which is how one depends on where the camera is or on what your resource knows at that moment.
The on-screen prompts follow the answers, so the player is never told about a control the view does not have. A view that turns exit off must close itself — from a handler with ctx.close(), or from your resource with Close.

Surface

What the interface draws around the map. Every field defaults to the hud configuration, so a view that says nothing looks like the standard map. A page the view does not list is neither drawn as a tab nor opened by OpenPage. instructional as a function is handed the prompts the capabilities produced, so a view adds to them rather than restating them.

Parameters

Open takes a second argument, passed through to the view. A view that declares params checks it and turns it into what its handlers receive; returning nothing refuses the open, which is how a view states that it cannot be shown without being told what to show.
SetViewParams changes them while the map stays open: the markers, the rules and the interface are all worked out again.

Handlers

Handlers live under on and are all optional. Each is given the context first. Returning anything other than true, including nothing, lets the map’s own behaviour run as well. That is how a view adds to a behaviour rather than replacing it. A handler that raises an error is reported and takes that one handler out of that one interaction; the map stays open. Handlers of a view and of the views it extends all run, this view’s own first, and the first one to return true ends the interaction.

The context

Following a view from another resource

A view’s on handlers belong to whoever registered it. Everybody else takes part through the SDK’s hooks, which give priorities, one-shot handlers and registration that goes away with the resource.
The argument is the same context the view’s own handlers are given, minus any knowledge of what its parameters mean. Only el:map:view:open is waited for, and only it can refuse anything: the other three are told what happened.

Outputs

RegisterView returns true when the view was accepted. It is available to Open from that moment and stays registered until the resource that registered it stops, or until RemoveView is called. Opening a view calls canOpen, then the el:map:view:open hook, then raises el:map:open and el:map:view:enter with the view’s id and calls onOpen. onReady follows once the camera has arrived. Closing raises el:map:view:leave and el:map:close. See Events. Registering a view that is already on screen applies the change to it: the limits, look, rules, interface and markers are taken from the new definition without the map closing. Removing it closes the map, because there is nothing left to show.

Errors

Opening an id that was never registered opens nothing, and says so in the console. This is a change from earlier releases, which fell back to the standard map. A view whose parameters are refused, whose canOpen says no, or whose el:map:view:open hook is refused by another resource, also opens nothing. The player is left where they were. A hook that raises, or that does not answer within its deadline, counts as agreement: the SDK’s hook dispatch reports it and carries on, so the map is not another resource’s to break by failing.

Example

A property viewer: its own markers, no destinations, opening over one house, and a title that follows what it was opened with.
Adding to the standard map instead of replacing it. The destination is still set, and the resource is told about it: