Skip to content

Embedding views and maps ​

Guide draft views embedding iframe mapp

Choosing between linking to a view, framing a view and using the MAPP package in another site, and what each needs from the XYZ instance; use when a map must appear outside the default view.

Resource and sources

There are three ways to show an XYZ map outside the default view.

A link to ${DIR}/view/<template>?… opens a custom view in its own tab. URL hooks pass the locale, view, layers and locations. The view runs on the XYZ origin, so the user's login works as usual. Report links from layers and locations work this way; see report views.

Frame a view ​

An <iframe> with the same URL shows the view inside another page. The ui reportLink element does this for report.dialog: true, from the same origin.[1]

  • From the same site the frame shares the user's login.
  • From another site the browser does not send the user cookie, which is SameSite=Strict by default (COOKIE_PROPS).[2] The frame is anonymous: a PRIVATE instance shows its login, and a PUBLIC instance shows only what needs no role.
  • Give the frame a fixed height; views size the map to the page.
  • A token URL param authenticates the request as the token's owner. MAPP removes it from the URL and the hooks when it loads.[3] Any page which holds the token can use it.

Use the MAPP package ​

A site can import @geolytix/mapp from npm or a CDN, set mapp.host to the XYZ instance and build its own mapview. MAPP.UI is not published, so such a page has no ui elements or ui plugins. The instance must list the site in CORS_ORIGINS. See the @geolytix/mapp package and the working page in packages/testhost/views/cdn.[4]

Choosing ​

NeedUse
A full page for a location or a print layoutLink to a view
A map inside a page on the same siteFrame a view
A map inside a page on another site, public dataMAPP package or frame
Restricted data on another siteHost the page on the XYZ origin, or a reverse proxy

Pitfalls ​

  • A framed view still writes URL hooks into the frame's URL, not the parent page's.
  • Do not hardcode the host in a view. Use data-dir=""; a hardcoded host breaks when DIR changes.

  1. elements/reportLink.mjs iFrameDialog ↩︎

  2. utils/processEnv.js COOKIE_PROPS ↩︎

  3. hooks.mjs parse ↩︎

  4. testhost views/cdn/cdn.mjs ↩︎

XYZ v5.1.0. Generated from knowledge/ at dd7a6fa27736502733499c1bf485f15659b10338. Concepts marked draft are not reviewed.