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.
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.
$ npm install @fxi/mxsdk
...
import {Manager} from '@fxi/mxsdk';
<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'
}
});
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.
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 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 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
Further usage resources:
- Observable collection to have an interactive showcase
- Examples within this repository
- Starter project example
- Prototype presentation (1-Jul-2020)
- Package at npm registry
- Wiki example
-
MapxResolversApp ⇐
MapxResolversStatic
-
MapX resolvers available in app only
-
MapxResolversPanels ⇐
ResolversBase
-
MapX resolvers for interacting with panels
-
MapxResolversStatic ⇐
MapxResolversPanels
-
MapX resolvers available in static and app
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>
-
.get_sdk_methods() ⇒
List resolvers methods
Kind: instance method of MapxResolversApp
Overrides: get_sdk_methods
Returns: Array
- array of supported methods
Show the login modal window
Kind: instance method of MapxResolversApp
Returns: Boolean
- done
Show view meta modal window
Kind: instance method of MapxResolversApp
Returns: Boolean
- done
Launch chaos test : open / close views by batch for a minute
Kind: instance method of MapxResolversApp
Returns: Boolean
- pass
Show view edit modal window
Kind: instance method of MapxResolversApp
Returns: Boolean
- done
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 |
Get user id
Kind: instance method of MapxResolversApp
Returns: Number
- Current user id
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 |
Retrieve MapX token.
Kind: instance method of MapxResolversApp
Returns: String
- MapX token.
Get user roles
Kind: instance method of MapxResolversApp
Returns: Object
- Current user roles
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 |
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 |
Get user email
Kind: instance method of MapxResolversApp
Returns: String
- Current user email ( if logged, null if not)
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 |
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 |
Get current project id
Kind: instance method of MapxResolversApp
Returns: String
- Current project id
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 |
Test if the current user is guest
Kind: instance method of MapxResolversApp
Returns: Boolean
- User is guest
Get views list state
Kind: instance method of MapxResolversApp
Get list of view in "open" state -> from the views list : possibly without layer
Kind: instance method of MapxResolversApp
Returns: Array
- Array of id
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'
})
Get views list filter rules
Kind: instance method of MapxResolversApp
Returns: Array
- Rule list
Get views current absolute order (without groups) in the list
Kind: instance method of MapxResolversApp
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 |
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'; |
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'; |
Move view on top of its group
Kind: instance method of MapxResolversApp
Returns: Boolean
- Done
Param | Type | Description |
---|---|---|
opt | Object |
Options |
opt.idView | Sring |
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 |
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 |
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 |
Move view up
Kind: instance method of MapxResolversApp
Returns: Boolean
- Done
Param | Type | Description |
---|---|---|
opt | Object |
Options |
opt.idView | Sring |
Move view down
Kind: instance method of MapxResolversApp
Returns: Boolean
- Done
Param | Type | Description |
---|---|---|
opt | Object |
Options |
opt.idView | Sring |
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 |
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 |
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 |
Get editable source list by current user
Kind: instance method of MapxResolversApp
Returns: Array
- Rows
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. |
Test if dashboard exists
Kind: instance method of MapxResolversApp
Returns: Boolean
- exists
End to end ws com testing
Kind: instance method of MapxResolversApp
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 |
Get immersive mode state
Kind: instance method of MapxResolversApp
Returns: Boolean
- Enabled
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' |
Enable or disable 3d terrain ( same as set_mode_3d;
Kind: instance method of MapxResolversApp
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' |
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 |
Close sharing modal
Kind: instance method of MapxResolversApp
Returns: Boolean
- Done
Get sharing string
Kind: instance method of MapxResolversApp
Returns: String
- Sharing string ( code / url )
Modal Share Tests Suite
Kind: instance method of MapxResolversApp
Returns: array
- array of tests
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. |
Get themes id
Kind: instance method of MapxResolversApp
Returns: Array
- array of themes id
Get all themes
Kind: instance method of MapxResolversApp
Returns: Object
- Themes object with themes id as key
Get current theme id
Kind: instance method of MapxResolversApp
Returns: string
- Theme id
Get all theme id
Kind: instance method of MapxResolversApp
Returns: Array.<string>
- Theme ids
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). |
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 |
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 |
Check if the dashboard is visible
Kind: instance method of MapxResolversApp
Returns: Promise.<Boolean>
- The dashboard is visible
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 |
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) |
Get user ip info
Kind: instance method of MapxResolversApp
Returns: Object
- Current user ip object (ip, country, region, etc)
Get current language
Kind: instance method of MapxResolversApp
Returns: String
- Two letters language code
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 |
Get list of supported current languages
Kind: instance method of MapxResolversApp
Returns: Array
- Array of two letters language code
Get list of available views as static objects
Kind: instance method of MapxResolversApp
Returns: Array
- Array of views
Get list of available views id
Kind: instance method of MapxResolversApp
Returns: Array
- Array of id
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 |
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 |
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 |
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 |
Get view table attribute url
Kind: instance method of MapxResolversApp
Param | Type | Description |
---|---|---|
opt | Object |
options |
opt.idView | String |
Id of the view |
Get view table attribute
Kind: instance method of MapxResolversApp
Param | Type | Description |
---|---|---|
opt | Object |
options |
opt.idView | String |
Id of the view |
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 |
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. |
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. |
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], ...]
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});
Get list views with visible layers
Kind: instance method of MapxResolversApp
Returns: Array
- Array of views
Get list views with visible layers (alias)
Kind: instance method of MapxResolversApp
Returns: Array
- Array of views
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) |
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 |
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) |
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 |
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,
});
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 |
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 |
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 |
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 |
remove a view
Kind: instance method of MapxResolversApp
Returns: Boolean
- done
Param | Type | Description |
---|---|---|
opt | Object |
Options |
opt.idView | String |
Target view id |
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 |
Get the download link of the raster source (same as download_view_source_external)
Kind: instance method of MapxResolversApp
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 |
Close download vector modal
Kind: instance method of MapxResolversApp
Returns: Boolean
- Done
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" |
Show map composer
Kind: instance method of MapxResolversApp
Returns: Boolean
- done
close all modal windows
Kind: instance method of MapxResolversApp
Returns: Boolean
- done
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 |
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 |
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"]],
],
},
],
});
Update highlighter using previous configuration i.e refresh features
Kind: instance method of MapxResolversApp
Returns: number
- Feature count
Clear all highlighted features and reset config
Kind: instance method of MapxResolversApp
Returns: number
- Feature count
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] |
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'}; |
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. |
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 |
Get map feature click handlers id
Kind: instance method of MapxResolversApp
Returns: Array
- Enabled modes
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});
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});
Get current map zoom
Kind: instance method of MapxResolversApp
Returns: Float
- zoom
Get current map center
Kind: instance method of MapxResolversApp
Returns: Object
- center
Get current map bounds as array
Kind: instance method of MapxResolversApp
Returns: Array
- Bounds [west, south, east, north]
Set current map bounds
Kind: instance method of MapxResolversApp
Param | Type | Description |
---|---|---|
opt | Object |
Options |
opt.bounds | array |
[west, south, east, north] |
Get current max bounds / world
Kind: instance method of MapxResolversApp
Returns: Array
| null
- bounds [west, south, east, north] or null
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 |
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);
Async wait for map idle
Kind: instance method of MapxResolversApp
Returns: Boolean
- Map is idle
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
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
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 |
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 |
MapX resolvers for interacting with panels
Kind: global class
Extends: ResolversBase
-
MapxResolversPanels ⇐
ResolversBase
-
.panels_batch(config) ⇒
void
-
.panels_state() ⇒
Object
-
.panels_list() ⇒
Promise.<Array.<string>>
-
.panels_close_all() ⇒
void
-
.panels_open_all() ⇒
void
-
.panels_hide_all() ⇒
void
-
.panels_show_all() ⇒
void
-
.panels_is_open(opt) ⇒
Promise.<boolean>
-
.panels_is_closed(opt) ⇒
Promise.<boolean>
-
.panels_is_visible(opt) ⇒
Promise.<boolean>
-
.panels_is_hidden(opt) ⇒
Promise.<boolean>
-
.panels_batch(config) ⇒
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
}
}
});
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
// }
// }
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', ...]
Closes all registered panels.
Kind: instance method of MapxResolversPanels
Opens all registered panels.
Kind: instance method of MapxResolversPanels
Hides all registered panels.
Kind: instance method of MapxResolversPanels
Shows all registered panels.
Kind: instance method of MapxResolversPanels
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. |
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. |
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 ⇐
MapxResolversPanels
-
.get_sdk_methods() ⇒
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>
-
.panels_batch(config) ⇒
void
-
.panels_state() ⇒
Object
-
.panels_list() ⇒
Promise.<Array.<string>>
-
.panels_close_all() ⇒
void
-
.panels_open_all() ⇒
void
-
.panels_hide_all() ⇒
void
-
.panels_show_all() ⇒
void
-
.panels_is_open(opt) ⇒
Promise.<boolean>
-
.panels_is_closed(opt) ⇒
Promise.<boolean>
-
.panels_is_visible(opt) ⇒
Promise.<boolean>
-
.panels_is_hidden(opt) ⇒
Promise.<boolean>
-
.get_sdk_methods() ⇒
List resolvers methods
Kind: instance method of MapxResolversStatic
Returns: Array
- array of supported methods
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. |
Test if dashboard exists
Kind: instance method of MapxResolversStatic
Returns: Boolean
- exists
End to end ws com testing
Kind: instance method of MapxResolversStatic
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 |
Get immersive mode state
Kind: instance method of MapxResolversStatic
Returns: Boolean
- Enabled
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' |
Enable or disable 3d terrain ( same as set_mode_3d;
Kind: instance method of MapxResolversStatic
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' |
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 |
Close sharing modal
Kind: instance method of MapxResolversStatic
Returns: Boolean
- Done
Get sharing string
Kind: instance method of MapxResolversStatic
Returns: String
- Sharing string ( code / url )
Modal Share Tests Suite
Kind: instance method of MapxResolversStatic
Returns: array
- array of tests
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. |
Get themes id
Kind: instance method of MapxResolversStatic
Returns: Array
- array of themes id
Get all themes
Kind: instance method of MapxResolversStatic
Returns: Object
- Themes object with themes id as key
Get current theme id
Kind: instance method of MapxResolversStatic
Returns: string
- Theme id
Get all theme id
Kind: instance method of MapxResolversStatic
Returns: Array.<string>
- Theme ids
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). |
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 |
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 |
Check if the dashboard is visible
Kind: instance method of MapxResolversStatic
Returns: Promise.<Boolean>
- The dashboard is visible
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 |
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) |
Get user ip info
Kind: instance method of MapxResolversStatic
Returns: Object
- Current user ip object (ip, country, region, etc)
Get current language
Kind: instance method of MapxResolversStatic
Returns: String
- Two letters language code
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 |
Get list of supported current languages
Kind: instance method of MapxResolversStatic
Returns: Array
- Array of two letters language code
Get list of available views as static objects
Kind: instance method of MapxResolversStatic
Returns: Array
- Array of views
Get list of available views id
Kind: instance method of MapxResolversStatic
Returns: Array
- Array of id
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 |
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 |
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 |
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 |
Get view table attribute url
Kind: instance method of MapxResolversStatic
Param | Type | Description |
---|---|---|
opt | Object |
options |
opt.idView | String |
Id of the view |
Get view table attribute
Kind: instance method of MapxResolversStatic
Param | Type | Description |
---|---|---|
opt | Object |
options |
opt.idView | String |
Id of the view |
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 |
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. |
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. |
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], ...]
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});
Get list views with visible layers
Kind: instance method of MapxResolversStatic
Returns: Array
- Array of views
Get list views with visible layers (alias)
Kind: instance method of MapxResolversStatic
Returns: Array
- Array of views
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) |
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 |
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) |
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 |
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,
});
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 |
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 |
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 |
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 |
remove a view
Kind: instance method of MapxResolversStatic
Returns: Boolean
- done
Param | Type | Description |
---|---|---|
opt | Object |
Options |
opt.idView | String |
Target view id |
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 |
Get the download link of the raster source (same as download_view_source_external)
Kind: instance method of MapxResolversStatic
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 |
Close download vector modal
Kind: instance method of MapxResolversStatic
Returns: Boolean
- Done
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" |
Show map composer
Kind: instance method of MapxResolversStatic
Returns: Boolean
- done
close all modal windows
Kind: instance method of MapxResolversStatic
Returns: Boolean
- done
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 |
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 |
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"]],
],
},
],
});
Update highlighter using previous configuration i.e refresh features
Kind: instance method of MapxResolversStatic
Returns: number
- Feature count
Clear all highlighted features and reset config
Kind: instance method of MapxResolversStatic
Returns: number
- Feature count
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] |
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'}; |
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. |
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 |
Get map feature click handlers id
Kind: instance method of MapxResolversStatic
Returns: Array
- Enabled modes
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});
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});
Get current map zoom
Kind: instance method of MapxResolversStatic
Returns: Float
- zoom
Get current map center
Kind: instance method of MapxResolversStatic
Returns: Object
- center
Get current map bounds as array
Kind: instance method of MapxResolversStatic
Returns: Array
- Bounds [west, south, east, north]
Set current map bounds
Kind: instance method of MapxResolversStatic
Param | Type | Description |
---|---|---|
opt | Object |
Options |
opt.bounds | array |
[west, south, east, north] |
Get current max bounds / world
Kind: instance method of MapxResolversStatic
Returns: Array
| null
- bounds [west, south, east, north] or null
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 |
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);
Async wait for map idle
Kind: instance method of MapxResolversStatic
Returns: Boolean
- Map is idle
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
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
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 |
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 |
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
}
}
});
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
// }
// }
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', ...]
Closes all registered panels.
Kind: instance method of MapxResolversStatic
Opens all registered panels.
Kind: instance method of MapxResolversStatic
Hides all registered panels.
Kind: instance method of MapxResolversStatic
Shows all registered panels.
Kind: instance method of MapxResolversStatic
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. |
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. |
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