@fxi/mxsdk

1.13.5-beta.3 • Public • Published

MapX SDK

The package MxSdk ease the integration of MapX. It features a simple way to interact with MapX within a static web page or from a full featured application.

Usage

As an integrator you will use the Manager class to embed an instance of MapX and allow to interact with MapX's specific methods or events.

Module include

$ npm install @fxi/mxsdk
...
import {Manager} from '@fxi/mxsdk';

HTML inline

<script src="https://app.mapx.org/sdk/mxsdk.umd.js"></script>
const mapx = new mxsdk.Manager({
  container: document.getElementById('mapx'),
  url: {
    host: 'app.mapx.org'
  },
  static: true,
  verbose: true,
  params: {
    closePanels: true,
    views: ['MX-Z741Z-HA4JJ-OGV29'],
    language: 'fr'
  }
});

Search parameters

Mapx has a set of valid search parameters in its query string. The SDK will use the params object to build the querry string.

Current supported parameters are defined in the wiki.

Methods and events

The ready event is the entry point on which methods are to be used; example:

/**
 * Embed a MapX instance
 */
const mapx = new Manager({
  container: document.getElementById('mapx'),
  url: 'https://app.mapx.org/?project=MX-YBJ-YYF-08R-UUR-QW6&language=en',
});

/**
 * Use methods upon the ready event
 */
mapx.on('ready', async () => {

  /**
   * Get list of views
   */
  const views = await mapx.ask('get_views')
  console.log(views);

  /**
   * Add a view to be displayed on the embedded map
   */
  await mapx.ask('view_add', {idView: 'MX-ML9PZ-PZ1SI-WVV85'});

  // Etc, ...

});

Methods

Methods are handled by the MapxResolvers class and are call using mapx.ask(<method name>[, <object param(s)>]) which returns a Promise or a Promisified value. E.g. mapx.ask('get_user_ip').then(console.log). In app mode, all methods from MapxResolvers app and MapxResolvers static are avaible. In static mode, only the subset from MapxResolvers static can be used.

Events

Events are hookable using Manager.on(<event name>, <callback>). Here are the available events.

SDK events:

  • message
  • ready

MapX events:

  • language_change
  • project_change
  • session_start
  • session_end
  • mapx_connected
  • mapx_disconnected
  • mapx_ready
  • click_attributes
  • views_list_updated
  • view_created
  • layers_ordered
  • view_deleted
  • view_remove
  • view_removed
  • view_filter
  • view_filtered
  • view_add
  • view_added
  • spotlight_progress
  • spotlight_update
  • settings_change
  • settings_user_change
  • story_step
  • view_panel_click

Resources

Further usage resources:

Documentation

Classes

MapxResolversAppMapxResolversStatic

MapX resolvers available in app only

MapxResolversPanelsResolversBase

MapX resolvers for interacting with panels

MapxResolversStaticMapxResolversPanels

MapX resolvers available in static and app

MapxResolversApp ⇐ MapxResolversStatic

MapX resolvers available in app only

Kind: global class
Extends: MapxResolversStatic

mapxResolversApp.get_sdk_methods() ⇒ Array

List resolvers methods

Kind: instance method of MapxResolversApp
Overrides: get_sdk_methods
Returns: Array - array of supported methods

mapxResolversApp.show_modal_login() ⇒ Boolean

Show the login modal window

Kind: instance method of MapxResolversApp
Returns: Boolean - done

mapxResolversApp.show_modal_view_meta() ⇒ Boolean

Show view meta modal window

Kind: instance method of MapxResolversApp
Returns: Boolean - done

mapxResolversApp.launch_chaos_test() ⇒ Boolean

Launch chaos test : open / close views by batch for a minute

Kind: instance method of MapxResolversApp
Returns: Boolean - pass

mapxResolversApp.show_modal_view_edit() ⇒ Boolean

Show view edit modal window

Kind: instance method of MapxResolversApp
Returns: Boolean - done

mapxResolversApp.show_modal_tool(opt) ⇒ Boolean | Array

Show modal for tools

Kind: instance method of MapxResolversApp
Returns: Boolean | Array - Done or the list of tools

Param Type Description
opt Object Options
opt.tool String Id of the tools
opt.list Boolean Return a list of tools

mapxResolversApp.get_user_id() ⇒ Number

Get user id

Kind: instance method of MapxResolversApp
Returns: Number - Current user id

mapxResolversApp.set_token(Mapx)

Manually set MapX app token and reload the app. This encrypted token is used to fingerprint user, browser and time since the last log in. It could be generated using MapX cryptography private key, or if not available, retrived from a live session with mx.helpers.getToken() or with the SDK, get_mapx_token.

Kind: instance method of MapxResolversApp

Param Type Description
Mapx String valid encrypted token

mapxResolversApp.get_token() ⇒ String

Retrieve MapX token.

Kind: instance method of MapxResolversApp
Returns: String - MapX token.

mapxResolversApp.get_user_roles() ⇒ Object

Get user roles

Kind: instance method of MapxResolversApp
Returns: Object - Current user roles

mapxResolversApp.check_user_role(opt) ⇒ Boolean

Check if user as given role

Kind: instance method of MapxResolversApp
Returns: Boolean - has role(s)

Param Type Description
opt Object Options
opt.role String | Array Role(s) to check
opt.all Boolean all roles must match, else at least one

mapxResolversApp.check_user_role_breaker(roleReq, opt) ⇒ Boolean

Check for any matching roles, send an error if it does not match

Kind: instance method of MapxResolversApp
Returns: Boolean - matched

Param Type Description
roleReq Array Array of required role. eg. ['members','admins']
opt Object Options
opt.reportError Boolean Report an error if no match (default true)
opt.id Any An identifier

mapxResolversApp.get_user_email() ⇒ String

Get user email

Kind: instance method of MapxResolversApp
Returns: String - Current user email ( if logged, null if not)

mapxResolversApp.set_project(opt) ⇒ Boolean

Set project

Kind: instance method of MapxResolversApp
Returns: Boolean - Done

Param Type Description
opt Object options
opt.idProject String Id of the project to switch to

mapxResolversApp.get_projects(opt) ⇒ Array

Get projects list

Kind: instance method of MapxResolversApp
Returns: Array - list of project for the current user, using optional filters

Param Type Description
opt Object Project fetching option

mapxResolversApp.get_project() ⇒ String

Get current project id

Kind: instance method of MapxResolversApp
Returns: String - Current project id

mapxResolversApp.get_project_collections(opt) ⇒ Array

Get list of collection for the current project

Kind: instance method of MapxResolversApp
Returns: Array - Array of collections names

Param Type Description
opt Object Options
opt.open Boolean Return only collections from open views

mapxResolversApp.is_user_guest() ⇒ Boolean

Test if the current user is guest

Kind: instance method of MapxResolversApp
Returns: Boolean - User is guest

mapxResolversApp.get_views_list_state() ⇒ Array

Get views list state

Kind: instance method of MapxResolversApp

mapxResolversApp.get_views_id_open() ⇒ Array

Get list of view in "open" state -> from the views list : possibly without layer

Kind: instance method of MapxResolversApp
Returns: Array - Array of id

mapxResolversApp.set_views_list_filters(opt) ⇒ Boolean

Set views list filter (ui)

Kind: instance method of MapxResolversApp
Returns: Boolean - done

Param Type Description
opt Object options
opt.reset Boolean Reset and remove all rules
opt.rules Array Array of filter object. e.g. {type:'text',value:'marine'}
opt.mode Boolean Set mode : 'intersection' or 'union';

Example

// reset all rules
mapx.ask('set_views_list_filter',{
   reset:true
})

// Reset rules and filter views with a dashboard
mapx.ask('set_views_list_filter',{
   reset: true,
   rules : [{
   type : 'view_components,
   value:'dashboard'
   }]
})

// All views with marine or earth in title or abstract or vector views or raster views
mapx.ask('set_views_list_filter',{
   rules:
    [
     {
          type: 'text',
          value: 'marine or earth'
      },
      {
          type: 'view_components',
          value: ['vt','rt']
      }
    ],
    mode: 'union'
  })

mapxResolversApp.get_views_list_filters() ⇒ Array

Get views list filter rules

Kind: instance method of MapxResolversApp
Returns: Array - Rule list

mapxResolversApp.get_views_list_order() ⇒ Array

Get views current absolute order (without groups) in the list

Kind: instance method of MapxResolversApp

mapxResolversApp.set_views_list_state(opt) ⇒ Boolean

Set state / views list order, groups, etc. Opened view will be closed

Kind: instance method of MapxResolversApp
Returns: Boolean - Done

Param Type Description
opt Object Options
opt.state Array Mapx views list state

mapxResolversApp.set_views_list_sort(opt) ⇒ Boolean

Set views list order

Kind: instance method of MapxResolversApp
Returns: Boolean - Done

Param Type Description
opt Object Options
opt.asc Boolean Asc
opt.mode String Mode : 'string' or 'date';

mapxResolversApp.is_views_list_sorted(opt) ⇒ Boolean

Test if views list is sorted

Kind: instance method of MapxResolversApp
Returns: Boolean - Sorted

Param Type Description
opt Object Options
opt.asc Boolean Asc
opt.mode String Mode : 'string' or 'date';

mapxResolversApp.move_view_top(opt) ⇒ Boolean

Move view on top of its group

Kind: instance method of MapxResolversApp
Returns: Boolean - Done

Param Type Description
opt Object Options
opt.idView Sring

mapxResolversApp.move_view_bottom(opt) ⇒ Boolean

Move view on the bottom of its group

Kind: instance method of MapxResolversApp
Returns: Boolean - Done

Param Type Description
opt Object Options
opt.idView Sring

mapxResolversApp.move_view_after(opt) ⇒ Boolean

Move view after anoter view

Kind: instance method of MapxResolversApp
Returns: Boolean - Done

Param Type Description
opt Object Options
opt.idView Sring
opt.idViewAfter Sring

mapxResolversApp.move_view_before(opt) ⇒ Boolean

Move view before another view

Kind: instance method of MapxResolversApp
Returns: Boolean - Done

Param Type Description
opt Object Options
opt.idView Sring
opt.idViewBefore Sring

mapxResolversApp.move_view_up(opt) ⇒ Boolean

Move view up

Kind: instance method of MapxResolversApp
Returns: Boolean - Done

Param Type Description
opt Object Options
opt.idView Sring

mapxResolversApp.move_view_down(opt) ⇒ Boolean

Move view down

Kind: instance method of MapxResolversApp
Returns: Boolean - Done

Param Type Description
opt Object Options
opt.idView Sring

mapxResolversApp.table_editor_open(opt) ⇒ Object

Show table editor ( require log in )

Kind: instance method of MapxResolversApp
Returns: Object - instance state

Param Type Description
opt Object Options
opt.id_table String id of the table to edit

mapxResolversApp.table_editor_close(opt) ⇒ Object

Close table editor

Kind: instance method of MapxResolversApp
Returns: Object - instance state

Param Type Description
opt Object Options
opt.id_table String id of the table to close

mapxResolversApp.table_editor_exec(opt) ⇒ Any

Apply any command on Table Editor Initially for testing purposes. May cause data loss.

Kind: instance method of MapxResolversApp
Returns: Any - res Result. If null, instance state

Param Type Description
opt Object Options
opt.id_table String Id of the table to edit
opt.method String Method name
opt.value Object Method arguments

mapxResolversApp.get_sources_list_edit() ⇒ Array

Get editable source list by current user

Kind: instance method of MapxResolversApp
Returns: Array - Rows

mapxResolversApp.set_panel_left_visibility(opt) ⇒ Boolean

Set panel visibility

Kind: instance method of MapxResolversApp
Returns: Boolean - done

Param Type Description
opt Object Options
opt.show Boolean Show the panel. If false, hide.
opt.open Boolean Open the panel. If false, close.
opt.toggle Boolean If closed, open. If open, close.

mapxResolversApp.has_dashboard() ⇒ Boolean

Test if dashboard exists

Kind: instance method of MapxResolversApp
Returns: Boolean - exists

mapxResolversApp.tests_ws()

End to end ws com testing

Kind: instance method of MapxResolversApp

mapxResolversApp.set_immersive_mode() ⇒ Boolean

Toogle immersive mode: hide or show ALL panels.

Kind: instance method of MapxResolversApp
Returns: Boolean - enabled
Aram: Object opt Options

Param Type Description
opt.enable Boolean Force enable
opt.toggle Boolean Toggle

mapxResolversApp.get_immersive_mode() ⇒ Boolean

Get immersive mode state

Kind: instance method of MapxResolversApp
Returns: Boolean - Enabled

mapxResolversApp.set_mode_3d(opt)

Enable or disable 3d terrain Set related layers visibility, change control buttons state

Kind: instance method of MapxResolversApp

Param Type Description
opt Object Options
opt.action String Action to perform: 'show','hide','toggle'

mapxResolversApp.set_3d_terrain()

Enable or disable 3d terrain ( same as set_mode_3d;

Kind: instance method of MapxResolversApp

mapxResolversApp.set_mode_aerial(opt)

Enable or disable aerial/satelite mode Set related layers visibility, change control buttons state

Kind: instance method of MapxResolversApp

Param Type Description
opt Object Options
opt.action String Action to perform: 'show','hide','toggle'

mapxResolversApp.show_modal_share(opt) ⇒ Boolean

Show sharing modal

Kind: instance method of MapxResolversApp
Returns: Boolean - Done

Param Type Description
opt Object Options
opt.idView String | Array Id view to share

mapxResolversApp.close_modal_share() ⇒ Boolean

Close sharing modal

Kind: instance method of MapxResolversApp
Returns: Boolean - Done

mapxResolversApp.get_modal_share_string() ⇒ String

Get sharing string

Kind: instance method of MapxResolversApp
Returns: String - Sharing string ( code / url )

mapxResolversApp.get_modal_share_tests() ⇒ array

Modal Share Tests Suite

Kind: instance method of MapxResolversApp
Returns: array - array of tests

mapxResolversApp.set_theme(opt) ⇒ Boolean

Set MapX theme by id or set custom colors. Both ways are exclusive.

Kind: instance method of MapxResolversApp
Returns: Boolean - done

Param Type Description
opt Object Options
opt.idTheme String Valid theme id. Use 'get_themes_id' to get a list
opt.colors Object Valid colors scheme. Use 'get_themes' to see default themes structure.

mapxResolversApp.get_themes_id() ⇒ Array

Get themes id

Kind: instance method of MapxResolversApp
Returns: Array - array of themes id

mapxResolversApp.get_themes() ⇒ Object

Get all themes

Kind: instance method of MapxResolversApp
Returns: Object - Themes object with themes id as key

mapxResolversApp.get_theme_id() ⇒ string

Get current theme id

Kind: instance method of MapxResolversApp
Returns: string - Theme id

mapxResolversApp.get_themes_ids() ⇒ Array.<string>

Get all theme id

Kind: instance method of MapxResolversApp
Returns: Array.<string> - Theme ids

mapxResolversApp.add_theme(opt) ⇒ Boolean

Add a custom theme into mapx and use it.

Kind: instance method of MapxResolversApp
Returns: Boolean - done

Param Type Description
opt Object Options
opt.theme String Valid theme (full).

mapxResolversApp.has_el_id(opt)

Check if element is visible, by id

Kind: instance method of MapxResolversApp

Param Type Description
opt Object Options
opt.id String Id of the element to check
opt.timeout Number Timeout

mapxResolversApp.set_dashboard_visibility(opt) ⇒ Boolean

Set dashboard visibility

Kind: instance method of MapxResolversApp
Returns: Boolean - done

Param Type Description
opt Object Options
opt.show Boolean If true, show the dashboard
opt.toggle Boolean Toggle the dashoard

mapxResolversApp.is_dashboard_visible() ⇒ Promise.<Boolean>

Check if the dashboard is visible

Kind: instance method of MapxResolversApp
Returns: Promise.<Boolean> - The dashboard is visible

mapxResolversApp.get_source_meta(opt) ⇒ Promise.<(Object|Array)>

Get source metadata

Kind: instance method of MapxResolversApp
Returns: Promise.<(Object|Array)> - Source MapX metadata, or array of meta

Param Type Description
opt Object Options
opt.idSource String Id of the source
opt.asArray Boolean In case of joined meta, returns an array

mapxResolversApp.get_view_source_summary(opt) ⇒ Object

Get view's source summary

Kind: instance method of MapxResolversApp
Returns: Object - Source summary

Param Type Description
opt Object Options
opt.idView String Id of the view
opt.stats Array Stats to retrieve. ['base', 'attributes', 'temporal', 'spatial']
opt.idAttr String Attribute for stat (default = attrbute of the style)

mapxResolversApp.get_user_ip() ⇒ Object

Get user ip info

Kind: instance method of MapxResolversApp
Returns: Object - Current user ip object (ip, country, region, etc)

mapxResolversApp.get_language() ⇒ String

Get current language

Kind: instance method of MapxResolversApp
Returns: String - Two letters language code

mapxResolversApp.set_language(opt) ⇒ Boolean

Setlanguage

Kind: instance method of MapxResolversApp
Returns: Boolean - Laguage change process finished

Param Type Description
opt Object Options
opt.lang String Two letters language code

mapxResolversApp.get_languages() ⇒ Array

Get list of supported current languages

Kind: instance method of MapxResolversApp
Returns: Array - Array of two letters language code

mapxResolversApp.get_views() ⇒ Array

Get list of available views as static objects

Kind: instance method of MapxResolversApp
Returns: Array - Array of views

mapxResolversApp.get_views_id() ⇒ Array

Get list of available views id

Kind: instance method of MapxResolversApp
Returns: Array - Array of id

mapxResolversApp.get_view_meta_vt_attribute(opt) ⇒ Object

Get vector view (vt) metadata of the attribute

Kind: instance method of MapxResolversApp
Returns: Object - attribut metadata

Param Type Description
opt Object Options
opt.idView String Id of the view

mapxResolversApp.get_view_meta(opt, view) ⇒ Promise.<Object>

Get view metadata

Kind: instance method of MapxResolversApp
Returns: Promise.<Object> - view metadata

Param Type Description
opt Object options
opt.idView String Id of the view
view Object meta data object

mapxResolversApp.get_view_source_meta(opt, view) ⇒ Promise.<(Object|Array)>

Get view source metadata

Kind: instance method of MapxResolversApp
Returns: Promise.<(Object|Array)> - view metadata

Param Type Description
opt Object options
opt.idView String Id of the view
opt.asArray Boolean In case of joined meta, returns an array
view Object meta data object

mapxResolversApp.get_view_table_attribute_config(opt) ⇒ Promise.<Object>

Get view table attribute config

Kind: instance method of MapxResolversApp
Returns: Promise.<Object> - view attribute config

Param Type Description
opt Object options
opt.idView String Id of the view

mapxResolversApp.get_view_table_attribute_url(opt) ⇒ Promise.<String>

Get view table attribute url

Kind: instance method of MapxResolversApp

Param Type Description
opt Object options
opt.idView String Id of the view

mapxResolversApp.get_view_table_attribute(opt) ⇒ Array.<Object>

Get view table attribute

Kind: instance method of MapxResolversApp

Param Type Description
opt Object options
opt.idView String Id of the view

mapxResolversApp.get_view_legend_image(opt) ⇒ String

Get view legend

Kind: instance method of MapxResolversApp
Returns: String - PNG in base64 format

Param Type Description
opt Object options
opt.idView String Id of the view
opt.format String

mapxResolversApp.set_view_legend_state(opt) ⇒ void | Error

Updates the state of a view's legend with the provided values.

Kind: instance method of MapxResolversApp
Returns: void | Error - Returns nothing if successful or an error if there's no LegendVt instance.

Param Type Description
opt Object options
opt.idView String | Object The view object containing the legend instance.
opt.values Array An array of values to set the legend's state.

mapxResolversApp.get_view_legend_state(opt) ⇒ Array | Error

Retrieves the current state (checked values) of a view's legend.

Kind: instance method of MapxResolversApp
Returns: Array | Error - An array of the currently checked values in the legend, or an error if there's no LegendVt instance.

Param Type Description
opt Object options
opt.idView String | Object The view id containing the legend instance.

mapxResolversApp.get_view_legend_values(opt) ⇒ Array

Retrieves the values from the legend.

For numeric rules, the method returns an array of range arrays ([from, to]), otherwise, it just returns an array of values.

Kind: instance method of MapxResolversApp
Returns: Array - An array of checked values. For numeric rules, each entry is an array of format [from, to].

Param Type Description
opt Object options
opt.idView String | Object The view id containing the legend instance.

Example

// Non-numeric rules
get_view_legend_values({view:"123"}); // e.g. ["value1", "value2", ...]

// Numeric rules
get_view_legend_values({view:"123"}); // e.g. [[0, 10], [10, 20], ...]

mapxResolversApp.set_views_layer_order(opt) ⇒ Boolean

Set view layer z position

Kind: instance method of MapxResolversApp
Returns: Boolean - Done

Param Type Description
opt Object Options
opt.order Array.<String> View order
opt.orig String Optional label for origin / logs

Example

const views = await mapx.ask("get_views_with_visible_layer");
const order = views.toReversed();
const result = await mapx.ask("set_views_layer_order",{order});

mapxResolversApp.get_views_layer_order() ⇒ Array

Get list views with visible layers

Kind: instance method of MapxResolversApp
Returns: Array - Array of views

mapxResolversApp.get_views_with_visible_layer() ⇒ Array

Get list views with visible layers (alias)

Kind: instance method of MapxResolversApp
Returns: Array - Array of views

mapxResolversApp.set_view_layer_filter_text(opt) ⇒ void

Filter view layer by text (if attribute is text)

Kind: instance method of MapxResolversApp

Param Type Description
opt Options Options
opt.idView String View id
opt.values array Values to use as filter
opt.attribute string Attribute to use as filter (default from style)

mapxResolversApp.get_view_layer_filter_text(opt) ⇒ array

Get current text filter values for a given view

Kind: instance method of MapxResolversApp
Returns: array - values

Param Type Description
opt.idView String View id
opt Options Options

mapxResolversApp.set_view_layer_filter_numeric(opt) ⇒ void

Filter view layer by numeric (if attribute is numeric)

Kind: instance method of MapxResolversApp

Param Type Description
opt Options Options
opt.idView String Target view id
opt.attribute String Attribute name (default from style)
opt.from Numeric Value
opt.to Numeric Value
opt.value array Values (Deprecated)

mapxResolversApp.get_view_layer_filter_numeric(opt) ⇒ Number | Array

Get current numeric slider value

Kind: instance method of MapxResolversApp
Returns: Number | Array - values

Param Type Description
opt Options Options
opt.idView String Target view id

mapxResolversApp.set_view_layer_filter_time(opt) ⇒ void

Filter view layer by time ( if posix mx_t0 and/or mx_t1 attributes exist )

This function creates a time filter based on the provided options and sets this filter to the specific view identified by its ID.

Kind: instance method of MapxResolversApp

Param Type Description
opt Object The options for the time filter.
opt.hasT0 boolean Flag indicating if the 'mx_t0' timestamp exists.
opt.hasT1 boolean Flag indicating if the 'mx_t1' timestamp exists.
opt.from number The 'from' timestamp for the filter in milliseconds.
opt.to number The 'to' timestamp for the filter in milliseconds.
opt.idView string The ID of the view to which the filter is to be applied.

Example

// Get summary ( any attribute: get_view_source_summary returns time extent
// by default )
const summary = await mapx.ask("get_view_source_summary", {
 idView,
 idAttr: idAttr,
 });
// set config + convert seconds -> milliseconds
const start = summary.extent_time.min * 1000;
const end = summary.extent_time.max * 1000;
const hasT0 = summary.attributes.includes("mx_t0");
const hasT1 = summary.attributes.includes("mx_t1");
await mapx.ask("set_view_layer_filter_time", {
 idView,
 from,
 to,
 hasT0,
 hasT1,
});

mapxResolversApp.get_view_layer_filter_time(opt) ⇒ Number | Array

Get current time slider value

Kind: instance method of MapxResolversApp
Returns: Number | Array - values

Param Type Description
opt Options Options
opt.idView String Target view id

mapxResolversApp.set_view_layer_transparency(opt) ⇒ void

Set layer transarency (0 : visible, 100 : 100% transparent)

Kind: instance method of MapxResolversApp

Param Type Description
opt Options Options
opt.idView String Target view id
opt.value Numeric Value

mapxResolversApp.get_view_layer_transparency(opt) ⇒ Number

Get current transparency value for layers of a view

Kind: instance method of MapxResolversApp
Returns: Number - value

Param Type Description
opt Options Options
opt.idView String Target view id

mapxResolversApp.view_add(opt) ⇒ Promise.<Boolean>

Add a view

Kind: instance method of MapxResolversApp
Returns: Promise.<Boolean> - done

Param Type Description
opt Object Options
opt.idView String Target view id
opt.zoomToView Boolean Fly to view extends

mapxResolversApp.view_remove(opt) ⇒ Boolean

remove a view

Kind: instance method of MapxResolversApp
Returns: Boolean - done

Param Type Description
opt Object Options
opt.idView String Target view id

mapxResolversApp.download_view_source_external(opt) ⇒ Object

Get the download links of an external source set in metadata (custom code, raster, etc)

Kind: instance method of MapxResolversApp
Returns: Object - input options, with new key : url. E.g. {idView:,url:,urlItems:[{,,<is_download_link>}]}

Param Type Description
opt Object Options
opt.idView String view view id

mapxResolversApp.download_view_source_raster()

Get the download link of the raster source (same as download_view_source_external)

Kind: instance method of MapxResolversApp

mapxResolversApp.download_view_source_vector(opt) ⇒ Object

Open the download modal for vector views

Kind: instance method of MapxResolversApp
Returns: Object - input options E.g. {idView:}

Param Type Description
opt Object Options
opt.idView String Vector view id

mapxResolversApp.close_modal_download_vector() ⇒ Boolean

Close download vector modal

Kind: instance method of MapxResolversApp
Returns: Boolean - Done

mapxResolversApp.download_view_source_geojson(opt) ⇒ Object

Get the data from geojson view or download geojsn as a file

Kind: instance method of MapxResolversApp
Returns: Object - input options E.g. {idView:, data:<data (if mode = data)>}

Param Type Description
opt Object Options
opt.idView String GeoJSON view id
opt.mode String "file" or "data"

mapxResolversApp.show_modal_map_composer() ⇒ Boolean

Show map composer

Kind: instance method of MapxResolversApp
Returns: Boolean - done

mapxResolversApp.close_modal_all() ⇒ Boolean

close all modal windows

Kind: instance method of MapxResolversApp
Returns: Boolean - done

mapxResolversApp.get_views_title(opt) ⇒ Array

Get list of views title

Kind: instance method of MapxResolversApp
Returns: Array - Array of titles (string)

Param Type Description
opt Object options
opt.views Array List of views or views id
opt.lang String Language code

mapxResolversApp.set_vector_spotlight(opt) ⇒ Object

Spotlight vector feature : Enable, disable, toggle

Kind: instance method of MapxResolversApp
Returns: Object - options realised {enable:<false/true>,calcArea:<true/false>,nLayers:}

Param Type Description
opt Object Options
opt.enable Boolean Enable or disable. If not set, toggle spotlight
opt.nLayers Number Numbers of layer that are used in the overlap tool. If not set, the default is 1 : any visible feature is spotlighted. If 0 = only part where all displayed layers are overlapping are spotligthed
opt.calcArea Boolean Estimate area covered by visible feature and display result in MapX interface

mapxResolversApp.set_highlighter(opt) ⇒ number

Set the highlighter with the provided options.

Kind: instance method of MapxResolversApp
Returns: number - Feature count

Param Type Description
opt Object Configuration options for the highlighter.
config.point PointLike | Array.<PointLike> Location to query
opt.filters Array.<Object> Array of filter objects to be applied.
opt.filters[].id String Identifier of the view to which the filter applies.
opt.filters[].filter Array MapboxGl filter expression

Example

mapx.ask('set_highlighter',{
  all: true,
});

mapx.ask('set_highlighter',{
  filters: [
    { id: "MX-TC0O1-34A9Y-RYDJG", filter: ["<", ["get", "year"], 2000] },
  ],
});

mapx.ask('set_highlighter',{
  filters: [
    { id: "MX-TC0O1-34A9Y-RYDJG", filter: [">=", ["get", "fatalities"], 7000] },
  ],
});

mapx.ask('set_highlighter',{
  filters: [
    {
      id: "MX-TC0O1-34A9Y-RYDJG",
      filter: [
        "in",
        ["get", "country"],
        ["literal", ["Nigeria", "Gabon", "Angola"]],
      ],
    },
  ],
});

mapxResolversApp.update_highlighter() ⇒ number

Update highlighter using previous configuration i.e refresh features

Kind: instance method of MapxResolversApp
Returns: number - Feature count

mapxResolversApp.reset_highlighter() ⇒ number

Clear all highlighted features and reset config

Kind: instance method of MapxResolversApp
Returns: number - Feature count

mapxResolversApp.view_geojson_create(opt) ⇒ Object

Add geojson. ( Other supported file type may be supported )

Kind: instance method of MapxResolversApp
Returns: Object - view

Param Type Description
opt Object Options
opt.data String | Object | Buffer Data : String,
opt.save Boolean Save locally, so next session the date will be loaded
opt.fileType String File type. e.g. geojson. default = geojson
opt.fileName String File name, if any
opt.title Sring Title
opt.abstract String Abstract
opt.random Object Generate random geojson
opt.random.n Number number of points
opt.random.latRange Array [minLat, maxLat]
opt.random.lngRange Array [minLng, maxLng]

mapxResolversApp.view_geojson_set_style(opt) ⇒ Boolean

Set geojson view layers style : layout and paint

Kind: instance method of MapxResolversApp
Returns: Boolean - done

Param Type Description
opt Object Options
opt.idView String Id of the geojson view
opt.layout Object Mapbox-gl layout object e.g. {'visibility','none'};
opt.paint Object Mapbox-gl paint object. e.g. {'fill-color':'red'};

mapxResolversApp.view_geojson_delete(opt) ⇒ Boolean

Delete view geojson Works with all view, but not permanently.

Kind: instance method of MapxResolversApp
Returns: Boolean - done

Param Type Description
opt Object Options
opt.idView String Id of the geojson view to delete.

mapxResolversApp.set_features_click_sdk_only(opt) ⇒ Array

Set map feature click handler to sdk only A listener could be set to listen to 'click_attributes' events. e.g. mapx.on('click_attributes') if this option is enabled, only the SDK will receive the attribute table.

Kind: instance method of MapxResolversApp
Returns: Array - Enabled modes

Param Type Description
opt Object Options
opt.enable Boolean Enable sdk only
opt.toggle Boolean Toggle this mode

mapxResolversApp.get_features_click_handlers() ⇒ Array

Get map feature click handlers id

Kind: instance method of MapxResolversApp
Returns: Array - Enabled modes

mapxResolversApp.map_fly_to(opt) ⇒ Promise.<Object>

Map flyTo position with flying animation

Kind: instance method of MapxResolversApp
Returns: Promise.<Object> - When moveend, the options

Param Type Description
opt Object Options see https://docs.mapbox.com/mapbox-gl-js/api/map/#map#flyto

Example

mapx.ask('map_fly_to',{center:[46,23], zoom:5});

mapxResolversApp.map_jump_to(opt) ⇒ Promise.<Object>

Map jumpTo position, without animation

Kind: instance method of MapxResolversApp
Returns: Promise.<Object> - When moveend, the options

Param Type Description
opt Object Options see https://docs.mapbox.com/mapbox-gl-js/api/map/#map#jumpto

Example

mapx.ask('set_map_jump_to',{lat:46,lng:23, zoom:5});

mapxResolversApp.map_get_zoom() ⇒ Float

Get current map zoom

Kind: instance method of MapxResolversApp
Returns: Float - zoom

mapxResolversApp.map_get_center() ⇒ Object

Get current map center

Kind: instance method of MapxResolversApp
Returns: Object - center

mapxResolversApp.map_get_bounds_array() ⇒ Array

Get current map bounds as array

Kind: instance method of MapxResolversApp
Returns: Array - Bounds [west, south, east, north]

mapxResolversApp.map_set_bounds_array(opt)

Set current map bounds

Kind: instance method of MapxResolversApp

Param Type Description
opt Object Options
opt.bounds array [west, south, east, north]

mapxResolversApp.map_get_max_bounds_array() ⇒ Array | null

Get current max bounds / world

Kind: instance method of MapxResolversApp
Returns: Array | null - bounds [west, south, east, north] or null

mapxResolversApp.map_set_max_bounds_array(opt) ⇒ boolean

Set current max bounds / world

Kind: instance method of MapxResolversApp
Returns: boolean - done

Param Type Description
opt Object Options
opt.bounds array [west, south, east, north] If empty or null = reset

mapxResolversApp.map(opt) ⇒ Promise.<(Any|Boolean)>

Generic map (mapbox-gl-js) methods This gives you low level access to the map methods. Most methods work, but not all. see https://docs.mapbox.com/mapbox-gl-js/api/map for all references

Kind: instance method of MapxResolversApp
Returns: Promise.<(Any|Boolean)> - If returned value can be parsed, the value. If not, true;

Param Type Description
opt Object Options
opt.method String Method/Instance member name (ex. setPaintProperty);
opt.parameters Array Array of parameters (ex. "['background', 'background-color', '#faafee']")

Example

mapx.ask('map',{
   method: 'setPaintProperty',
   parameters : ['background', 'background-color', '#faafee']
}).then(console.table);

mapxResolversApp.map_wait_idle() ⇒ Boolean

Async wait for map idle

Kind: instance method of MapxResolversApp
Returns: Boolean - Map is idle

mapxResolversApp.common_loc_get_list_codes() ⇒ Array

Get list of common location codes Codes as defined in ISO 3166-1 alpha-3 (ex. AFG, COD) and UN M49 region codes (ex. m49_901)

Kind: instance method of MapxResolversApp
Returns: Array - Array of codes as strings

mapxResolversApp.common_loc_get_table_codes(opt) ⇒ Promise.<Array>

Get table of common location codes and names Same as common_loc_get_list_codes, but with names in set language. ex. [{code:"ABW",name:"Aruba"},...]

Kind: instance method of MapxResolversApp
Returns: Promise.<Array> - Array of codes and name as object

Param Type Description
opt Object Options
opt.language String Language (ISO 639-1 two letters code, default 'en')

Example

mapx.ask('common_loc_get_table_codes',{
   language: english
}).then(console.table);
// code  name
// -----------------
// ABW   Aruba
// AFG   Afghanistan
// AGO   Angola
// AIA   Anguilla

mapxResolversApp.common_loc_get_bbox(o) ⇒ Promise.<Array>

Get Bounding box for code iso3, m49 and text + language

Kind: instance method of MapxResolversApp
Returns: Promise.<Array> - Array of geographic bounds [west, south, east, north]

Param Type Description
o Object options
o.code String | Array.<string> Code: ISO 3166-1 alpha-3 (iso3) or UN M49 region code. E.g. 'COD','m49_004'
o.name String | Array.<string> Name (alternative to code, less recommanded): Country or region mame. e.g. Africa, Bangladesh

mapxResolversApp.common_loc_fit_bbox(o) ⇒ Promise.<Array>

Set map bounding box based on code (ISO 3166-1 alpha-3 (ex. AFG, COD) and UN M49 region codes) or name (ex. Africa)

Kind: instance method of MapxResolversApp
Returns: Promise.<Array> - Array of geographic bounds [west, south, east, north]

Param Type Description
o Object options
o.code String | Array.<string> Code: ISO 3166-1 alpha-3 (iso3) or UN M49 region code. E.g. 'COD','m49_004'
o.name String | Array.<string> Name (alternative to code, less recommanded): Country or region mame. e.g. Africa, Bangladesh
o.param Object Animation options, see https://docs.mapbox.com/mapbox-gl-js/api/properties/#animationoptions

MapxResolversPanels ⇐ ResolversBase

MapX resolvers for interacting with panels

Kind: global class
Extends: ResolversBase

mapxResolversPanels.panels_batch(config) ⇒ void

Applies a batch state to panels based on the provided configuration.

Kind: instance method of MapxResolversPanels

Param Type Description
config Object The configuration object that maps panel IDs to their desired state.

Example

// Example usage :
mapx.ask('panels_batch',{
    "controls_panel": {
      "show": true,
      "open": true
    }
  }
});

mapxResolversPanels.panels_state() ⇒ Object

Retrieves current state.

Kind: instance method of MapxResolversPanels
Returns: Object - config - The configuration object that maps panel IDs to their desired state.
Example

// Example usage :
const state = await mapx.ask('panels_state');
console.log(state);
//  {
//  "controls_panel": {
//   "hide": false,
//   "open": true
//   }
//  }

mapxResolversPanels.panels_list() ⇒ Promise.<Array.<string>>

Lists all registered panel IDs.

Kind: instance method of MapxResolversPanels
Returns: Promise.<Array.<string>> - A promise that resolves to an array of panel IDs.
Example

const panelIds = await mapx.ask('panels_list');
console.log(panelIds);  // Outputs: ['panel_1', 'panel_2', ...]

mapxResolversPanels.panels_close_all() ⇒ void

Closes all registered panels.

Kind: instance method of MapxResolversPanels

mapxResolversPanels.panels_open_all() ⇒ void

Opens all registered panels.

Kind: instance method of MapxResolversPanels

mapxResolversPanels.panels_hide_all() ⇒ void

Hides all registered panels.

Kind: instance method of MapxResolversPanels

mapxResolversPanels.panels_show_all() ⇒ void

Shows all registered panels.

Kind: instance method of MapxResolversPanels

mapxResolversPanels.panels_is_open(opt) ⇒ Promise.<boolean>

Checks if a panel is open.

Kind: instance method of MapxResolversPanels
Returns: Promise.<boolean> - True if the panel is open, false otherwise.

Param Type Description
opt Object Config
opt.id string The panel ID.

mapxResolversPanels.panels_is_closed(opt) ⇒ Promise.<boolean>

Checks if a panel is closed.

Kind: instance method of MapxResolversPanels
Returns: Promise.<boolean> - True if the panel is closed, false otherwise.

Param Type Description
opt Object Config
opt.id string The panel ID.

mapxResolversPanels.panels_is_visible(opt) ⇒ Promise.<boolean>

Checks if a panel is visible.

Kind: instance method of MapxResolversPanels
Returns: Promise.<boolean> - True if the panel is visible, false otherwise.

Param Type Description
opt Object Config
opt.id string The panel ID.

mapxResolversPanels.panels_is_hidden(opt) ⇒ Promise.<boolean>

Checks if a panel is hidden.

Kind: instance method of MapxResolversPanels
Returns: Promise.<boolean> - True if the panel is hidden, false otherwise.

Param Type Description
opt Object Config
opt.id string The panel ID.

MapxResolversStatic ⇐ MapxResolversPanels

MapX resolvers available in static and app

Kind: global class
Extends: MapxResolversPanels

mapxResolversStatic.get_sdk_methods() ⇒ Array

List resolvers methods

Kind: instance method of MapxResolversStatic
Returns: Array - array of supported methods

mapxResolversStatic.set_panel_left_visibility(opt) ⇒ Boolean

Set panel visibility

Kind: instance method of MapxResolversStatic
Returns: Boolean - done

Param Type Description
opt Object Options
opt.show Boolean Show the panel. If false, hide.
opt.open Boolean Open the panel. If false, close.
opt.toggle Boolean If closed, open. If open, close.

mapxResolversStatic.has_dashboard() ⇒ Boolean

Test if dashboard exists

Kind: instance method of MapxResolversStatic
Returns: Boolean - exists

mapxResolversStatic.tests_ws()

End to end ws com testing

Kind: instance method of MapxResolversStatic

mapxResolversStatic.set_immersive_mode() ⇒ Boolean

Toogle immersive mode: hide or show ALL panels.

Kind: instance method of MapxResolversStatic
Returns: Boolean - enabled
Aram: Object opt Options

Param Type Description
opt.enable Boolean Force enable
opt.toggle Boolean Toggle

mapxResolversStatic.get_immersive_mode() ⇒ Boolean

Get immersive mode state

Kind: instance method of MapxResolversStatic
Returns: Boolean - Enabled

mapxResolversStatic.set_mode_3d(opt)

Enable or disable 3d terrain Set related layers visibility, change control buttons state

Kind: instance method of MapxResolversStatic

Param Type Description
opt Object Options
opt.action String Action to perform: 'show','hide','toggle'

mapxResolversStatic.set_3d_terrain()

Enable or disable 3d terrain ( same as set_mode_3d;

Kind: instance method of MapxResolversStatic

mapxResolversStatic.set_mode_aerial(opt)

Enable or disable aerial/satelite mode Set related layers visibility, change control buttons state

Kind: instance method of MapxResolversStatic

Param Type Description
opt Object Options
opt.action String Action to perform: 'show','hide','toggle'

mapxResolversStatic.show_modal_share(opt) ⇒ Boolean

Show sharing modal

Kind: instance method of MapxResolversStatic
Returns: Boolean - Done

Param Type Description
opt Object Options
opt.idView String | Array Id view to share

mapxResolversStatic.close_modal_share() ⇒ Boolean

Close sharing modal

Kind: instance method of MapxResolversStatic
Returns: Boolean - Done

mapxResolversStatic.get_modal_share_string() ⇒ String

Get sharing string

Kind: instance method of MapxResolversStatic
Returns: String - Sharing string ( code / url )

mapxResolversStatic.get_modal_share_tests() ⇒ array

Modal Share Tests Suite

Kind: instance method of MapxResolversStatic
Returns: array - array of tests

mapxResolversStatic.set_theme(opt) ⇒ Boolean

Set MapX theme by id or set custom colors. Both ways are exclusive.

Kind: instance method of MapxResolversStatic
Returns: Boolean - done

Param Type Description
opt Object Options
opt.idTheme String Valid theme id. Use 'get_themes_id' to get a list
opt.colors Object Valid colors scheme. Use 'get_themes' to see default themes structure.

mapxResolversStatic.get_themes_id() ⇒ Array

Get themes id

Kind: instance method of MapxResolversStatic
Returns: Array - array of themes id

mapxResolversStatic.get_themes() ⇒ Object

Get all themes

Kind: instance method of MapxResolversStatic
Returns: Object - Themes object with themes id as key

mapxResolversStatic.get_theme_id() ⇒ string

Get current theme id

Kind: instance method of MapxResolversStatic
Returns: string - Theme id

mapxResolversStatic.get_themes_ids() ⇒ Array.<string>

Get all theme id

Kind: instance method of MapxResolversStatic
Returns: Array.<string> - Theme ids

mapxResolversStatic.add_theme(opt) ⇒ Boolean

Add a custom theme into mapx and use it.

Kind: instance method of MapxResolversStatic
Returns: Boolean - done

Param Type Description
opt Object Options
opt.theme String Valid theme (full).

mapxResolversStatic.has_el_id(opt)

Check if element is visible, by id

Kind: instance method of MapxResolversStatic

Param Type Description
opt Object Options
opt.id String Id of the element to check
opt.timeout Number Timeout

mapxResolversStatic.set_dashboard_visibility(opt) ⇒ Boolean

Set dashboard visibility

Kind: instance method of MapxResolversStatic
Returns: Boolean - done

Param Type Description
opt Object Options
opt.show Boolean If true, show the dashboard
opt.toggle Boolean Toggle the dashoard

mapxResolversStatic.is_dashboard_visible() ⇒ Promise.<Boolean>

Check if the dashboard is visible

Kind: instance method of MapxResolversStatic
Returns: Promise.<Boolean> - The dashboard is visible

mapxResolversStatic.get_source_meta(opt) ⇒ Promise.<(Object|Array)>

Get source metadata

Kind: instance method of MapxResolversStatic
Returns: Promise.<(Object|Array)> - Source MapX metadata, or array of meta

Param Type Description
opt Object Options
opt.idSource String Id of the source
opt.asArray Boolean In case of joined meta, returns an array

mapxResolversStatic.get_view_source_summary(opt) ⇒ Object

Get view's source summary

Kind: instance method of MapxResolversStatic
Returns: Object - Source summary

Param Type Description
opt Object Options
opt.idView String Id of the view
opt.stats Array Stats to retrieve. ['base', 'attributes', 'temporal', 'spatial']
opt.idAttr String Attribute for stat (default = attrbute of the style)

mapxResolversStatic.get_user_ip() ⇒ Object

Get user ip info

Kind: instance method of MapxResolversStatic
Returns: Object - Current user ip object (ip, country, region, etc)

mapxResolversStatic.get_language() ⇒ String

Get current language

Kind: instance method of MapxResolversStatic
Returns: String - Two letters language code

mapxResolversStatic.set_language(opt) ⇒ Boolean

Setlanguage

Kind: instance method of MapxResolversStatic
Returns: Boolean - Laguage change process finished

Param Type Description
opt Object Options
opt.lang String Two letters language code

mapxResolversStatic.get_languages() ⇒ Array

Get list of supported current languages

Kind: instance method of MapxResolversStatic
Returns: Array - Array of two letters language code

mapxResolversStatic.get_views() ⇒ Array

Get list of available views as static objects

Kind: instance method of MapxResolversStatic
Returns: Array - Array of views

mapxResolversStatic.get_views_id() ⇒ Array

Get list of available views id

Kind: instance method of MapxResolversStatic
Returns: Array - Array of id

mapxResolversStatic.get_view_meta_vt_attribute(opt) ⇒ Object

Get vector view (vt) metadata of the attribute

Kind: instance method of MapxResolversStatic
Returns: Object - attribut metadata

Param Type Description
opt Object Options
opt.idView String Id of the view

mapxResolversStatic.get_view_meta(opt, view) ⇒ Promise.<Object>

Get view metadata

Kind: instance method of MapxResolversStatic
Returns: Promise.<Object> - view metadata

Param Type Description
opt Object options
opt.idView String Id of the view
view Object meta data object

mapxResolversStatic.get_view_source_meta(opt, view) ⇒ Promise.<(Object|Array)>

Get view source metadata

Kind: instance method of MapxResolversStatic
Returns: Promise.<(Object|Array)> - view metadata

Param Type Description
opt Object options
opt.idView String Id of the view
opt.asArray Boolean In case of joined meta, returns an array
view Object meta data object

mapxResolversStatic.get_view_table_attribute_config(opt) ⇒ Promise.<Object>

Get view table attribute config

Kind: instance method of MapxResolversStatic
Returns: Promise.<Object> - view attribute config

Param Type Description
opt Object options
opt.idView String Id of the view

mapxResolversStatic.get_view_table_attribute_url(opt) ⇒ Promise.<String>

Get view table attribute url

Kind: instance method of MapxResolversStatic

Param Type Description
opt Object options
opt.idView String Id of the view

mapxResolversStatic.get_view_table_attribute(opt) ⇒ Array.<Object>

Get view table attribute

Kind: instance method of MapxResolversStatic

Param Type Description
opt Object options
opt.idView String Id of the view

mapxResolversStatic.get_view_legend_image(opt) ⇒ String

Get view legend

Kind: instance method of MapxResolversStatic
Returns: String - PNG in base64 format

Param Type Description
opt Object options
opt.idView String Id of the view
opt.format String

mapxResolversStatic.set_view_legend_state(opt) ⇒ void | Error

Updates the state of a view's legend with the provided values.

Kind: instance method of MapxResolversStatic
Returns: void | Error - Returns nothing if successful or an error if there's no LegendVt instance.

Param Type Description
opt Object options
opt.idView String | Object The view object containing the legend instance.
opt.values Array An array of values to set the legend's state.

mapxResolversStatic.get_view_legend_state(opt) ⇒ Array | Error

Retrieves the current state (checked values) of a view's legend.

Kind: instance method of MapxResolversStatic
Returns: Array | Error - An array of the currently checked values in the legend, or an error if there's no LegendVt instance.

Param Type Description
opt Object options
opt.idView String | Object The view id containing the legend instance.

mapxResolversStatic.get_view_legend_values(opt) ⇒ Array

Retrieves the values from the legend.

For numeric rules, the method returns an array of range arrays ([from, to]), otherwise, it just returns an array of values.

Kind: instance method of MapxResolversStatic
Returns: Array - An array of checked values. For numeric rules, each entry is an array of format [from, to].

Param Type Description
opt Object options
opt.idView String | Object The view id containing the legend instance.

Example

// Non-numeric rules
get_view_legend_values({view:"123"}); // e.g. ["value1", "value2", ...]

// Numeric rules
get_view_legend_values({view:"123"}); // e.g. [[0, 10], [10, 20], ...]

mapxResolversStatic.set_views_layer_order(opt) ⇒ Boolean

Set view layer z position

Kind: instance method of MapxResolversStatic
Returns: Boolean - Done

Param Type Description
opt Object Options
opt.order Array.<String> View order
opt.orig String Optional label for origin / logs

Example

const views = await mapx.ask("get_views_with_visible_layer");
const order = views.toReversed();
const result = await mapx.ask("set_views_layer_order",{order});

mapxResolversStatic.get_views_layer_order() ⇒ Array

Get list views with visible layers

Kind: instance method of MapxResolversStatic
Returns: Array - Array of views

mapxResolversStatic.get_views_with_visible_layer() ⇒ Array

Get list views with visible layers (alias)

Kind: instance method of MapxResolversStatic
Returns: Array - Array of views

mapxResolversStatic.set_view_layer_filter_text(opt) ⇒ void

Filter view layer by text (if attribute is text)

Kind: instance method of MapxResolversStatic

Param Type Description
opt Options Options
opt.idView String View id
opt.values array Values to use as filter
opt.attribute string Attribute to use as filter (default from style)

mapxResolversStatic.get_view_layer_filter_text(opt) ⇒ array

Get current text filter values for a given view

Kind: instance method of MapxResolversStatic
Returns: array - values

Param Type Description
opt.idView String View id
opt Options Options

mapxResolversStatic.set_view_layer_filter_numeric(opt) ⇒ void

Filter view layer by numeric (if attribute is numeric)

Kind: instance method of MapxResolversStatic

Param Type Description
opt Options Options
opt.idView String Target view id
opt.attribute String Attribute name (default from style)
opt.from Numeric Value
opt.to Numeric Value
opt.value array Values (Deprecated)

mapxResolversStatic.get_view_layer_filter_numeric(opt) ⇒ Number | Array

Get current numeric slider value

Kind: instance method of MapxResolversStatic
Returns: Number | Array - values

Param Type Description
opt Options Options
opt.idView String Target view id

mapxResolversStatic.set_view_layer_filter_time(opt) ⇒ void

Filter view layer by time ( if posix mx_t0 and/or mx_t1 attributes exist )

This function creates a time filter based on the provided options and sets this filter to the specific view identified by its ID.

Kind: instance method of MapxResolversStatic

Param Type Description
opt Object The options for the time filter.
opt.hasT0 boolean Flag indicating if the 'mx_t0' timestamp exists.
opt.hasT1 boolean Flag indicating if the 'mx_t1' timestamp exists.
opt.from number The 'from' timestamp for the filter in milliseconds.
opt.to number The 'to' timestamp for the filter in milliseconds.
opt.idView string The ID of the view to which the filter is to be applied.

Example

// Get summary ( any attribute: get_view_source_summary returns time extent
// by default )
const summary = await mapx.ask("get_view_source_summary", {
 idView,
 idAttr: idAttr,
 });
// set config + convert seconds -> milliseconds
const start = summary.extent_time.min * 1000;
const end = summary.extent_time.max * 1000;
const hasT0 = summary.attributes.includes("mx_t0");
const hasT1 = summary.attributes.includes("mx_t1");
await mapx.ask("set_view_layer_filter_time", {
 idView,
 from,
 to,
 hasT0,
 hasT1,
});

mapxResolversStatic.get_view_layer_filter_time(opt) ⇒ Number | Array

Get current time slider value

Kind: instance method of MapxResolversStatic
Returns: Number | Array - values

Param Type Description
opt Options Options
opt.idView String Target view id

mapxResolversStatic.set_view_layer_transparency(opt) ⇒ void

Set layer transarency (0 : visible, 100 : 100% transparent)

Kind: instance method of MapxResolversStatic

Param Type Description
opt Options Options
opt.idView String Target view id
opt.value Numeric Value

mapxResolversStatic.get_view_layer_transparency(opt) ⇒ Number

Get current transparency value for layers of a view

Kind: instance method of MapxResolversStatic
Returns: Number - value

Param Type Description
opt Options Options
opt.idView String Target view id

mapxResolversStatic.view_add(opt) ⇒ Promise.<Boolean>

Add a view

Kind: instance method of MapxResolversStatic
Returns: Promise.<Boolean> - done

Param Type Description
opt Object Options
opt.idView String Target view id
opt.zoomToView Boolean Fly to view extends

mapxResolversStatic.view_remove(opt) ⇒ Boolean

remove a view

Kind: instance method of MapxResolversStatic
Returns: Boolean - done

Param Type Description
opt Object Options
opt.idView String Target view id

mapxResolversStatic.download_view_source_external(opt) ⇒ Object

Get the download links of an external source set in metadata (custom code, raster, etc)

Kind: instance method of MapxResolversStatic
Returns: Object - input options, with new key : url. E.g. {idView:,url:,urlItems:[{,,<is_download_link>}]}

Param Type Description
opt Object Options
opt.idView String view view id

mapxResolversStatic.download_view_source_raster()

Get the download link of the raster source (same as download_view_source_external)

Kind: instance method of MapxResolversStatic

mapxResolversStatic.download_view_source_vector(opt) ⇒ Object

Open the download modal for vector views

Kind: instance method of MapxResolversStatic
Returns: Object - input options E.g. {idView:}

Param Type Description
opt Object Options
opt.idView String Vector view id

mapxResolversStatic.close_modal_download_vector() ⇒ Boolean

Close download vector modal

Kind: instance method of MapxResolversStatic
Returns: Boolean - Done

mapxResolversStatic.download_view_source_geojson(opt) ⇒ Object

Get the data from geojson view or download geojsn as a file

Kind: instance method of MapxResolversStatic
Returns: Object - input options E.g. {idView:, data:<data (if mode = data)>}

Param Type Description
opt Object Options
opt.idView String GeoJSON view id
opt.mode String "file" or "data"

mapxResolversStatic.show_modal_map_composer() ⇒ Boolean

Show map composer

Kind: instance method of MapxResolversStatic
Returns: Boolean - done

mapxResolversStatic.close_modal_all() ⇒ Boolean

close all modal windows

Kind: instance method of MapxResolversStatic
Returns: Boolean - done

mapxResolversStatic.get_views_title(opt) ⇒ Array

Get list of views title

Kind: instance method of MapxResolversStatic
Returns: Array - Array of titles (string)

Param Type Description
opt Object options
opt.views Array List of views or views id
opt.lang String Language code

mapxResolversStatic.set_vector_spotlight(opt) ⇒ Object

Spotlight vector feature : Enable, disable, toggle

Kind: instance method of MapxResolversStatic
Returns: Object - options realised {enable:<false/true>,calcArea:<true/false>,nLayers:}

Param Type Description
opt Object Options
opt.enable Boolean Enable or disable. If not set, toggle spotlight
opt.nLayers Number Numbers of layer that are used in the overlap tool. If not set, the default is 1 : any visible feature is spotlighted. If 0 = only part where all displayed layers are overlapping are spotligthed
opt.calcArea Boolean Estimate area covered by visible feature and display result in MapX interface

mapxResolversStatic.set_highlighter(opt) ⇒ number

Set the highlighter with the provided options.

Kind: instance method of MapxResolversStatic
Returns: number - Feature count

Param Type Description
opt Object Configuration options for the highlighter.
config.point PointLike | Array.<PointLike> Location to query
opt.filters Array.<Object> Array of filter objects to be applied.
opt.filters[].id String Identifier of the view to which the filter applies.
opt.filters[].filter Array MapboxGl filter expression

Example

mapx.ask('set_highlighter',{
  all: true,
});

mapx.ask('set_highlighter',{
  filters: [
    { id: "MX-TC0O1-34A9Y-RYDJG", filter: ["<", ["get", "year"], 2000] },
  ],
});

mapx.ask('set_highlighter',{
  filters: [
    { id: "MX-TC0O1-34A9Y-RYDJG", filter: [">=", ["get", "fatalities"], 7000] },
  ],
});

mapx.ask('set_highlighter',{
  filters: [
    {
      id: "MX-TC0O1-34A9Y-RYDJG",
      filter: [
        "in",
        ["get", "country"],
        ["literal", ["Nigeria", "Gabon", "Angola"]],
      ],
    },
  ],
});

mapxResolversStatic.update_highlighter() ⇒ number

Update highlighter using previous configuration i.e refresh features

Kind: instance method of MapxResolversStatic
Returns: number - Feature count

mapxResolversStatic.reset_highlighter() ⇒ number

Clear all highlighted features and reset config

Kind: instance method of MapxResolversStatic
Returns: number - Feature count

mapxResolversStatic.view_geojson_create(opt) ⇒ Object

Add geojson. ( Other supported file type may be supported )

Kind: instance method of MapxResolversStatic
Returns: Object - view

Param Type Description
opt Object Options
opt.data String | Object | Buffer Data : String,
opt.save Boolean Save locally, so next session the date will be loaded
opt.fileType String File type. e.g. geojson. default = geojson
opt.fileName String File name, if any
opt.title Sring Title
opt.abstract String Abstract
opt.random Object Generate random geojson
opt.random.n Number number of points
opt.random.latRange Array [minLat, maxLat]
opt.random.lngRange Array [minLng, maxLng]

mapxResolversStatic.view_geojson_set_style(opt) ⇒ Boolean

Set geojson view layers style : layout and paint

Kind: instance method of MapxResolversStatic
Returns: Boolean - done

Param Type Description
opt Object Options
opt.idView String Id of the geojson view
opt.layout Object Mapbox-gl layout object e.g. {'visibility','none'};
opt.paint Object Mapbox-gl paint object. e.g. {'fill-color':'red'};

mapxResolversStatic.view_geojson_delete(opt) ⇒ Boolean

Delete view geojson Works with all view, but not permanently.

Kind: instance method of MapxResolversStatic
Returns: Boolean - done

Param Type Description
opt Object Options
opt.idView String Id of the geojson view to delete.

mapxResolversStatic.set_features_click_sdk_only(opt) ⇒ Array

Set map feature click handler to sdk only A listener could be set to listen to 'click_attributes' events. e.g. mapx.on('click_attributes') if this option is enabled, only the SDK will receive the attribute table.

Kind: instance method of MapxResolversStatic
Returns: Array - Enabled modes

Param Type Description
opt Object Options
opt.enable Boolean Enable sdk only
opt.toggle Boolean Toggle this mode

mapxResolversStatic.get_features_click_handlers() ⇒ Array

Get map feature click handlers id

Kind: instance method of MapxResolversStatic
Returns: Array - Enabled modes

mapxResolversStatic.map_fly_to(opt) ⇒ Promise.<Object>

Map flyTo position with flying animation

Kind: instance method of MapxResolversStatic
Returns: Promise.<Object> - When moveend, the options

Param Type Description
opt Object Options see https://docs.mapbox.com/mapbox-gl-js/api/map/#map#flyto

Example

mapx.ask('map_fly_to',{center:[46,23], zoom:5});

mapxResolversStatic.map_jump_to(opt) ⇒ Promise.<Object>

Map jumpTo position, without animation

Kind: instance method of MapxResolversStatic
Returns: Promise.<Object> - When moveend, the options

Param Type Description
opt Object Options see https://docs.mapbox.com/mapbox-gl-js/api/map/#map#jumpto

Example

mapx.ask('set_map_jump_to',{lat:46,lng:23, zoom:5});

mapxResolversStatic.map_get_zoom() ⇒ Float

Get current map zoom

Kind: instance method of MapxResolversStatic
Returns: Float - zoom

mapxResolversStatic.map_get_center() ⇒ Object

Get current map center

Kind: instance method of MapxResolversStatic
Returns: Object - center

mapxResolversStatic.map_get_bounds_array() ⇒ Array

Get current map bounds as array

Kind: instance method of MapxResolversStatic
Returns: Array - Bounds [west, south, east, north]

mapxResolversStatic.map_set_bounds_array(opt)

Set current map bounds

Kind: instance method of MapxResolversStatic

Param Type Description
opt Object Options
opt.bounds array [west, south, east, north]

mapxResolversStatic.map_get_max_bounds_array() ⇒ Array | null

Get current max bounds / world

Kind: instance method of MapxResolversStatic
Returns: Array | null - bounds [west, south, east, north] or null

mapxResolversStatic.map_set_max_bounds_array(opt) ⇒ boolean

Set current max bounds / world

Kind: instance method of MapxResolversStatic
Returns: boolean - done

Param Type Description
opt Object Options
opt.bounds array [west, south, east, north] If empty or null = reset

mapxResolversStatic.map(opt) ⇒ Promise.<(Any|Boolean)>

Generic map (mapbox-gl-js) methods This gives you low level access to the map methods. Most methods work, but not all. see https://docs.mapbox.com/mapbox-gl-js/api/map for all references

Kind: instance method of MapxResolversStatic
Returns: Promise.<(Any|Boolean)> - If returned value can be parsed, the value. If not, true;

Param Type Description
opt Object Options
opt.method String Method/Instance member name (ex. setPaintProperty);
opt.parameters Array Array of parameters (ex. "['background', 'background-color', '#faafee']")

Example

mapx.ask('map',{
   method: 'setPaintProperty',
   parameters : ['background', 'background-color', '#faafee']
}).then(console.table);

mapxResolversStatic.map_wait_idle() ⇒ Boolean

Async wait for map idle

Kind: instance method of MapxResolversStatic
Returns: Boolean - Map is idle

mapxResolversStatic.common_loc_get_list_codes() ⇒ Array

Get list of common location codes Codes as defined in ISO 3166-1 alpha-3 (ex. AFG, COD) and UN M49 region codes (ex. m49_901)

Kind: instance method of MapxResolversStatic
Returns: Array - Array of codes as strings

mapxResolversStatic.common_loc_get_table_codes(opt) ⇒ Promise.<Array>

Get table of common location codes and names Same as common_loc_get_list_codes, but with names in set language. ex. [{code:"ABW",name:"Aruba"},...]

Kind: instance method of MapxResolversStatic
Returns: Promise.<Array> - Array of codes and name as object

Param Type Description
opt Object Options
opt.language String Language (ISO 639-1 two letters code, default 'en')

Example

mapx.ask('common_loc_get_table_codes',{
   language: english
}).then(console.table);
// code  name
// -----------------
// ABW   Aruba
// AFG   Afghanistan
// AGO   Angola
// AIA   Anguilla

mapxResolversStatic.common_loc_get_bbox(o) ⇒ Promise.<Array>

Get Bounding box for code iso3, m49 and text + language

Kind: instance method of MapxResolversStatic
Returns: Promise.<Array> - Array of geographic bounds [west, south, east, north]

Param Type Description
o Object options
o.code String | Array.<string> Code: ISO 3166-1 alpha-3 (iso3) or UN M49 region code. E.g. 'COD','m49_004'
o.name String | Array.<string> Name (alternative to code, less recommanded): Country or region mame. e.g. Africa, Bangladesh

mapxResolversStatic.common_loc_fit_bbox(o) ⇒ Promise.<Array>

Set map bounding box based on code (ISO 3166-1 alpha-3 (ex. AFG, COD) and UN M49 region codes) or name (ex. Africa)

Kind: instance method of MapxResolversStatic
Returns: Promise.<Array> - Array of geographic bounds [west, south, east, north]

Param Type Description
o Object options
o.code String | Array.<string> Code: ISO 3166-1 alpha-3 (iso3) or UN M49 region code. E.g. 'COD','m49_004'
o.name String | Array.<string> Name (alternative to code, less recommanded): Country or region mame. e.g. Africa, Bangladesh
o.param Object Animation options, see https://docs.mapbox.com/mapbox-gl-js/api/properties/#animationoptions

mapxResolversStatic.panels_batch(config) ⇒ void

Applies a batch state to panels based on the provided configuration.

Kind: instance method of MapxResolversStatic

Param Type Description
config Object The configuration object that maps panel IDs to their desired state.

Example

// Example usage :
mapx.ask('panels_batch',{
    "controls_panel": {
      "show": true,
      "open": true
    }
  }
});

mapxResolversStatic.panels_state() ⇒ Object

Retrieves current state.

Kind: instance method of MapxResolversStatic
Returns: Object - config - The configuration object that maps panel IDs to their desired state.
Example

// Example usage :
const state = await mapx.ask('panels_state');
console.log(state);
//  {
//  "controls_panel": {
//   "hide": false,
//   "open": true
//   }
//  }

mapxResolversStatic.panels_list() ⇒ Promise.<Array.<string>>

Lists all registered panel IDs.

Kind: instance method of MapxResolversStatic
Returns: Promise.<Array.<string>> - A promise that resolves to an array of panel IDs.
Example

const panelIds = await mapx.ask('panels_list');
console.log(panelIds);  // Outputs: ['panel_1', 'panel_2', ...]

mapxResolversStatic.panels_close_all() ⇒ void

Closes all registered panels.

Kind: instance method of MapxResolversStatic

mapxResolversStatic.panels_open_all() ⇒ void

Opens all registered panels.

Kind: instance method of MapxResolversStatic

mapxResolversStatic.panels_hide_all() ⇒ void

Hides all registered panels.

Kind: instance method of MapxResolversStatic

mapxResolversStatic.panels_show_all() ⇒ void

Shows all registered panels.

Kind: instance method of MapxResolversStatic

mapxResolversStatic.panels_is_open(opt) ⇒ Promise.<boolean>

Checks if a panel is open.

Kind: instance method of MapxResolversStatic
Returns: Promise.<boolean> - True if the panel is open, false otherwise.

Param Type Description
opt Object Config
opt.id string The panel ID.

mapxResolversStatic.panels_is_closed(opt) ⇒ Promise.<boolean>

Checks if a panel is closed.

Kind: instance method of MapxResolversStatic
Returns: Promise.<boolean> - True if the panel is closed, false otherwise.

Param Type Description
opt Object Config
opt.id string The panel ID.

mapxResolversStatic.panels_is_visible(opt) ⇒ Promise.<boolean>

Checks if a panel is visible.

Kind: instance method of MapxResolversStatic
Returns: Promise.<boolean> - True if the panel is visible, false otherwise.

Param Type Description
opt Object Config
opt.id string The panel ID.

mapxResolversStatic.panels_is_hidden(opt) ⇒ Promise.<boolean>

Checks if a panel is hidden.

Kind: instance method of MapxResolversStatic
Returns: Promise.<boolean> - True if the panel is hidden, false otherwise.

Param Type Description
opt Object Config
opt.id string The panel ID.

© 2019-present unepgrid.ch

Readme

Keywords

Package Sidebar

Install

npm i @fxi/mxsdk

Weekly Downloads

350

Version

1.13.5-beta.3

License

MIT

Unpacked Size

957 kB

Total Files

29

Last publish

Collaborators

  • fxi