LiveComposedSplit (split view)

Markup: {{livecomposedsplit}}

Quick start

The example below, running in the Mappia calculator - click it to run it live. Full-size picture

  1. Run it

    Click the picture: the map opens right here and runs the example. Nothing is saved, and nothing to install.

  2. Try it
    • Press Compare months, then drag the divider: January on the left, August on the right.
    • While comparing, pick November in the Right list: the right side of the map switches to November.
    • Press the swap button (⇄): the two months change sides and the divider stays where it is.
  3. Make it yours

    Copy the query, change it - the key parameters are below - and run it again in the playground, or paste it into the Mappia editor to save it as your map.

Key parameters

ParameterExampleWhat it does
layerNamesprecip_monthly_average_1,precip_monthly_average_4,precip_monthly_average_8,precip_monthly_average_11Styles offered on each side, matched by position with displayNames.
displayNamesJanuary,April,August,NovemberLabels shown in the Left and Right lists. Same count and order as layerNames.
leftDefaultJanuaryStarting choice on the left. Must be one of displayNames.
rightDefaultAugustStarting choice on the right. Must be one of displayNames and differ from leftDefault.
baseNameCSR:precip_monthly_averageThe map both sides show. Defaults to the layer’s own map.
textCompare monthsLabel of the Compare button. While comparing, the button reads Close comparison.

Every parameter, with its type and default, is in the reference at the end of this page.

Complete example

The query 19 lines · runs as is
// LiveComposedSplit: compare January and August precipitation side by side.
// Open the layer's panel and press "Compare months"; drag the divider across the map.
[
  {
    title: "Monthly precipitation",
    // the same map twice - one copy for each side of the divider
    name: "CSR:precip_monthly_average,CSR:precip_monthly_average",
    styles: "precip_monthly_average_1,precip_monthly_average_8",
    source: "calculate",
    opacity: 0.8,
    visibility: true,
    paramsButtonConfig: [{ type: "query", pressed: true }],
    descriptionHtml:
      "{{livecomposedsplit|id=example_split|text=Compare months" +
      "|displayNames=January,April,August,November" +
      "|layerNames=precip_monthly_average_1,precip_monthly_average_4,precip_monthly_average_8,precip_monthly_average_11" +
      "|baseName=CSR:precip_monthly_average|leftDefault=January|rightDefault=August}}",
  },
];

Customize it

How it works

The tag needs a composed layer: a source: "calculate" layer whose name lists the same map twice, with one entry in styles for each copy. Before Compare is pressed, only the Left list is active and the whole map shows the left choice. When the user presses Compare, the left copy takes the left style, the right copy takes the right style, and each copy is clipped to its side of the divider. Pressing the button again, or hiding the layer, goes back to a single style.

Open the layer’s panel with paramsButtonConfig: [{ type: "query", pressed: true }], otherwise users do not see the button.

More options

ParameterUse
idId of the Compare button. The panel around it is id + "_container".
layoutcompact (default, stacked to fit the layer card) or inline (one row).
composedLayerNameThe layer to split. Without it, the first calculated layer on the map is used, so set it when your map has several.
clsExtra CSS class for the Compare button.

Control it from code

The methods belong to the panel, Ext.getCmp(id + "_container"), not to the button:

var split = Ext.getCmp("example_split_container");
if (split.isComparisonActive()) {
  split.swapSides();                        // exchange left and right
}
split.setComparisonEditingEnabled(false);   // lock the Right list and swap while data loads
split.refreshActiveSplit();                 // after your own changeLayers on the layer

destroySplitControl() removes the divider for good. It comes back the next time Compare is pressed.

Pitfalls

  • displayNames and layerNames must have the same number of items, in the same order.
  • Every name in layerNames must be a style the map is published with.
  • While comparing, the two sides cannot show the same choice.
  • Both sides show baseName with different styles. The tool does not compare two different maps.

Reference: every parameter

Generated from the platform source. Every entry, searchable, is in the API reference; the raw data is api.json. Open an entry for its description, parameters and example; # links to it.

livecomposedsplit · split-screen comparison

LiveComposedSplit16 entries

Written in a layer's descriptionHtml as {{livecomposedsplit|parameter=value|...}}

Compare two styles of a Composed layer with a live split-screen slider on the map.

The layer must be a Composed layer (typically the same WMS layer twice in `name` with two `styles`). Put the tool in `descriptionHtml`, open the query panel, choose left/right styles, then press Compare to show a draggable vertical divider.

Required parameters: displayNames, layerNames (same order and length). Recommended: id, baseName, leftDefault, rightDefault. Optional: layout=compact (default, stacked for the layer card) or layout=inline (legacy single row).

Usage: {{livecomposedsplit|id=...|displayNames=...|layerNames=...|baseName=...|leftDefault=...|rightDefault=...}}
View the complete LiveComposedSplit API here.

applySelectedStyles

function()# Pushes the two selected styles to the composed layer (changeLayers with the left style on child 0 and the right style on child 1) and makes both children visible.

Pushes the two selected styles to the composed layer (changeLayers with the left style on child 0 and the right style on child 1) and makes both children visible. Called when Compare is pressed; after calling it yourself use refreshActiveSplit() so the divider clips the new child divs.

Ext.getCmp('precip_split_container').applySelectedStyles();

baseName

String# WMS layer name used with each style (e.g. CSR:precip_monthly_average).

WMS layer name used with each style (e.g. CSR:precip_monthly_average). Defaults to layer.params.LAYERS when omitted.

|baseName=CSR:precip_monthly_average|

cls

String# Extra CSS class for the Compare toggle button (replaces the default clickable; the class live-composed-split-compare is always added).

Extra CSS class for the Compare toggle button (replaces the default clickable; the class live-composed-split-compare is always added).

|cls=my-compare-button|

composedLayerName

String# Name of the Composed layer to split.

Name of the Composed layer to split. If omitted, the first OpenLayers.Layer.Composed on the map is used.

|composedLayerName=CSR:precip_monthly_average|

destroySplitControl

function()# Removes the split divider control from the map for good (it is recreated on the next Compare press).

Removes the split divider control from the map for good (it is recreated on the next Compare press). The panel calls it when its layer is removed; call it to force a clean state. It does not restore the single-style view — press the Compare button off (toggle(false)) for the normal close.

Ext.getCmp('precip_split_container').destroySplitControl();

displayNames

String# Comma-separated labels shown in the left/right combo boxes (required).

Comma-separated labels shown in the left/right combo boxes (required).

|displayNames=January,February,March,April,May,June,July,August,September,October,November,December|

id

String# Id of the Compare button (wrapper id is id + "_container").

Id of the Compare button (wrapper id is id + "_container").

|id=my_composed_split|

isComparisonActive

function() : Boolean# Tells whether the split comparison is currently shown on the map (Compare pressed and the divider active).

Tells whether the split comparison is currently shown on the map (Compare pressed and the divider active). Get the panel with Ext.getCmp(id + '_container'), where id is the markup id.

Returns true while the two styles are being compared.

if (Ext.getCmp('precip_split_container').isComparisonActive()) { ... }

layerNames

String# Comma-separated WMS style names aligned with displayNames (required).

Comma-separated WMS style names aligned with displayNames (required). When Compare is pressed, the composed layer switches to the selected pair.

|layerNames=precip_monthly_average_1,precip_monthly_average_2,...|

layout

String= compact# Presentation inside the layer query panel. compact (default): stacked fields that fit the ~300px layer card. inline: horizontal row (legacy Left / Right / Compare on one line).

Presentation inside the layer query panel. compact (default): stacked fields that fit the ~300px layer card. inline: horizontal row (legacy Left / Right / Compare on one line).

|layout=inline|

leftDefault

String# Initial left combo value; must be one of displayNames.

Initial left combo value; must be one of displayNames.

|leftDefault=January|

refreshActiveSplit

function()# Re-applies the selected styles and re-clips the split after the composed layer's children were replaced (e.g. by your own changeLayers call), keeping the divider position.

Re-applies the selected styles and re-clips the split after the composed layer's children were replaced (e.g. by your own changeLayers call), keeping the divider position. Does nothing while the comparison is not active.

Ext.getCmp('precip_split_container').refreshActiveSplit();

rightDefault

String# Initial right combo value; must be one of displayNames (and different from left).

Initial right combo value; must be one of displayNames (and different from left).

|rightDefault=August|

setComparisonEditingEnabled

function(enabled)# Enables or disables the right-side combo and the swap button.

Enables or disables the right-side combo and the swap button. The panel calls it itself (only the left combo is editable while idle; both unlock when comparing); call it to lock the choice while data loads.

enabled Boolean
true to allow changing the right side and swapping, false to lock them.
Ext.getCmp('precip_split_container').setComparisonEditingEnabled(false);

swapSides

function()# Exchanges the left and right styles (combos and map) and re-clips the split, keeping the divider where it is.

Exchanges the left and right styles (combos and map) and re-clips the split, keeping the divider where it is. Does nothing while the comparison is not active — what the swap button does.

Ext.getCmp('precip_split_container').swapSides();

text

String= Compare Layers# Label on the Compare toggle button (before the split is active).

Label on the Compare toggle button (before the split is active).

|text=Compare Monthly Data|