@fxi/mxsdk
v1.13.1-3.1
Published
sdk for mapx app
Downloads
1,421
Readme
MapX SDK
Introduction
The MapX SDK enables developers to seamlessly integrate the MapX single page application into web projects, providing access to comprehensive geospatial environmental data. Key MapX features include:
- Scientific and geospatial visualizations
- Curated list of thousands of views, including geological maps, or near real-time data, e.g., Active Fires Assessment, or Near Real-Time Active Fires
- UN official boundaries base maps, customizable themes, styles, and fonts, including GL fonts
- Dashboards
- Story maps
- Vector drawing tools
- Multi-user, real-time attribute table editing
- Many more : projects, users management, complex join, upload, download, metadata, WMS ...
The SDK aims to embed MapX and simplify interaction with it. Although it doesn't include all of MapX's functionalities, it offers most features essential for seamless integration into other web applications.
The primary usage is in 'static' mode: a lightweight, performant version of MapX without login and user roles. Alternatively, the 'app' mode provides a more comprehensive version of MapX with enhanced control but is more complex and resource-intensive.
License
The MapX SDK is provided under an MIT license
Resources
- Mapx Documentation
- Demo site with example of integration in React, JQuery or Vanilla JS, with a link to the source code
- Observable collection / Showcase
- Starter project example
- Prototype presentation (1-Jul-2020)
- Package at npm registry
- Wiki example
- A paper [unpublished] is available in the repo
Installation and Configuration
To get started, include the MapX SDK.
For the latest version that match the guest's version, e.g. https://app.mapx.org
you can use ES6 imports:
import { Manager } from "https://app.mapx.org/sdk/mxsdk.modern.js";
Classic npm
package installation
$ npm install @fxi/mxsdk
...
import { Manager } from '@fxi/mxsdk';
Basic Usage
- Create a new MapX manager instance:
const mapx = new Manager({
// where to render MapX
container: document.getElementById("mapx"),
// instance to connect to
url: "https://app.mapx.org:443",
// mode static ( recommended )
static : true,
// additional search parameters
params: {
theme: "color_light",
project: "MX-YBJ-YYF-08R-UUR-QW6",
// Most UN languages supported
language : "fr"
},
});
- Handle the
ready
event and call theask
method to interact with MapX:
mapx.once("ready", async () => {
console.log("ready!");
const res = await mapx.ask("<command>", "<config>");
// Your logic here
});
Search Parameters params
MapX has a set of valid search parameters in its query string. The SDK uses the params
object to build the initial query string, which already covers a lot of ground.
Current supported parameters are defined in the wiki.
Methods
ask(<command>, <config>)
Sends a command to the MapX API and returns the result.
Parameters:
command
(string): The command identifier.config
(object): The command configuration object.
Example:
// Test if user is guest
const isGuest = await mapx.ask("is_user_guest");
console.log(`User is guest: ${isGuest}`);
// List available commands
const methods = await mapx.ask("get_sdk_methods");
console.log(`Methods: ${JSON.stringify(methods,0,2)}`);
// Create a sample GeoJSON
const view = await mapx.ask("view_geojson_create", {
random: { n: 100 },
save: false,
});
const res = await mapx.ask("download_view_source_geojson", {
idView: view.id,
});
console.log(res.data);
// Add a view
await mapx.ask('view_add', {idView: 'MX-ML9PZ-PZ1SI-WVV85'});
on(event, callback)
once(event, callback)
off(event, callback)
Adds an event listener for the specified event.
- Parameters:
event
(string): The event name.callback
(function): The callback function to execute when the event is triggered.
- Example:
mapx.on("message",log);
mapx.off("message", log);
function log(m){console.log(m)};
// once can use a callback
mapx.once("ready", ()=>{console.log('ready'});
// and returns a promise
const res = await mapx.once('view_panel_click');
Events
MapX SDK provides several events that can be listened for via the .on
and .once
methods:
ready
- Fired when the SDK is fully loaded and initialized.
- Usage:
mapx.once("ready", () => {
console.log("MapX SDK is ready!");
});
message
- Triggered when there is a message from
mapx
or theworker
. - Usage:
- Triggered when there is a message from
mapx.on("message", (message) => {
const { level, text } = message;
switch (level) {
case "message":
console.info(text);
break;
case "warning":
console.warn(text);
break;
case "error":
console.error(text);
break;
default:
console.log(message);
}
});
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
Commands Documentation
Classes
MapxResolversApp ⇐ MapxResolversStatic
MapX resolvers available in app only
Kind: global class
Extends: MapxResolversStatic
- MapxResolversApp ⇐ MapxResolversStatic
- .get_sdk_methods() ⇒ Array
- .show_modal_login() ⇒ Boolean
- .show_modal_view_meta() ⇒ Boolean
- .launch_chaos_test() ⇒ Boolean
- .show_modal_view_edit() ⇒ Boolean
- .show_modal_tool(opt) ⇒ Boolean | Array
- .get_user_id() ⇒ Number
- .set_token(Mapx)
- .get_token() ⇒ String
- .get_user_roles() ⇒ Object
- .check_user_role(opt) ⇒ Boolean
- .check_user_role_breaker(roleReq, opt) ⇒ Boolean
- .get_user_email() ⇒ String
- .set_project(opt) ⇒ Boolean
- .get_projects(opt) ⇒ Array
- .get_project() ⇒ String
- .get_project_collections(opt) ⇒ Array
- .is_user_guest() ⇒ Boolean
- .get_views_list_state() ⇒ Array
- .get_views_id_open() ⇒ Array
- .set_views_list_filters(opt) ⇒ Boolean
- .get_views_list_filters() ⇒ Array
- .get_views_list_order() ⇒ Array
- .set_views_list_state(opt) ⇒ Boolean
- .set_views_list_sort(opt) ⇒ Boolean
- .is_views_list_sorted(opt) ⇒ Boolean
- .move_view_top(opt) ⇒ Boolean
- .move_view_bottom(opt) ⇒ Boolean
- .move_view_after(opt) ⇒ Boolean
- .move_view_before(opt) ⇒ Boolean
- .move_view_up(opt) ⇒ Boolean
- .move_view_down(opt) ⇒ Boolean
- .table_editor_open(opt) ⇒ Object
- .table_editor_close(opt) ⇒ Object
- .table_editor_exec(opt) ⇒ Any
- .get_sources_list_edit() ⇒ Array
- .set_panel_left_visibility(opt) ⇒ Boolean
- .has_dashboard() ⇒ Boolean
- .tests_ws()
- .set_immersive_mode() ⇒ Boolean
- .get_immersive_mode() ⇒ Boolean
- .set_mode_3d(opt)
- .set_3d_terrain()
- .set_mode_aerial(opt)
- .show_modal_share(opt) ⇒ Boolean
- .close_modal_share() ⇒ Boolean
- .get_modal_share_string() ⇒ String
- .get_modal_share_tests() ⇒ array
- .set_theme(opt) ⇒ Boolean
- .get_themes_id() ⇒ Array
- .get_themes() ⇒ Object
- .get_theme_id() ⇒ string
- .get_themes_ids() ⇒ Array.<string>
- .add_theme(opt) ⇒ Boolean
- .has_el_id(opt)
- .set_dashboard_visibility(opt) ⇒ Boolean
- .is_dashboard_visible() ⇒ Promise.<Boolean>
- .get_source_meta(opt) ⇒ Promise.<(Object|Array)>
- .get_view_source_summary(opt) ⇒ Object
- .get_user_ip() ⇒ Object
- .get_language() ⇒ String
- .set_language(opt) ⇒ Boolean
- .get_languages() ⇒ Array
- .get_views() ⇒ Array
- .get_views_id() ⇒ Array
- .get_view_meta_vt_attribute(opt) ⇒ Object
- .get_view_meta(opt, view) ⇒ Promise.<Object>
- .get_view_source_meta(opt, view) ⇒ Promise.<(Object|Array)>
- .get_view_table_attribute_config(opt) ⇒ Promise.<Object>
- .get_view_table_attribute_url(opt) ⇒ Promise.<String>
- .get_view_table_attribute(opt) ⇒ Array.<Object>
- .get_view_legend_image(opt) ⇒ String
- .set_view_legend_state(opt) ⇒ void | Error
- .get_view_legend_state(opt) ⇒ Array | Error
- .get_view_legend_values(opt) ⇒ Array
- .set_views_layer_order(opt) ⇒ Boolean
- .get_views_layer_order() ⇒ Array
- .get_views_with_visible_layer() ⇒ Array
- .set_view_layer_filter_text(opt) ⇒ void
- .get_view_layer_filter_text(opt) ⇒ array
- .set_view_layer_filter_numeric(opt) ⇒ void
- .get_view_layer_filter_numeric(opt) ⇒ Number | Array
- .set_view_layer_filter_time(opt) ⇒ void
- .get_view_layer_filter_time(opt) ⇒ Number | Array
- .set_view_layer_transparency(opt) ⇒ void
- .get_view_layer_transparency(opt) ⇒ Number
- .view_add(opt) ⇒ Promise.<Boolean>
- .view_remove(opt) ⇒ Boolean
- .download_view_source_external(opt) ⇒ Object
- .download_view_source_raster()
- .download_view_source_vector(opt) ⇒ Object
- .close_modal_download_vector() ⇒ Boolean
- .download_view_source_geojson(opt) ⇒ Object
- .show_modal_map_composer() ⇒ Boolean
- .close_modal_all() ⇒ Boolean
- .get_views_title(opt) ⇒ Array
- .set_vector_spotlight(opt) ⇒ Object
- .set_highlighter(opt) ⇒ number
- .update_highlighter() ⇒ number
- .reset_highlighter() ⇒ number
- .view_geojson_create(opt) ⇒ Object
- .view_geojson_set_style(opt) ⇒ Boolean
- .view_geojson_delete(opt) ⇒ Boolean
- .set_features_click_sdk_only(opt) ⇒ Array
- .get_features_click_handlers() ⇒ Array
- .map_fly_to(opt) ⇒ Promise.<Object>
- .map_jump_to(opt) ⇒ Promise.<Object>
- .map_get_zoom() ⇒ Float
- .map_get_center() ⇒ Object
- .map_get_bounds_array() ⇒ Array
- .map_set_bounds_array(opt)
- .map_get_max_bounds_array() ⇒ Array | null
- .map_set_max_bounds_array(opt) ⇒ boolean
- .map(opt) ⇒ Promise.<(Any|Boolean)>
- .map_wait_idle() ⇒ Boolean
- .common_loc_get_list_codes() ⇒ Array
- .common_loc_get_table_codes(opt) ⇒ Promise.<Array>
- .common_loc_get_bbox(o) ⇒ Promise.<Array>
- .common_loc_fit_bbox(o) ⇒ Promise.<Array>
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 pa