Members
MapStoreAPI
Properties:
| Name | Type | Description |
|---|---|---|
getMapState |
function | return the map state if available |
triggerAction |
function | dispatch an action |
onAction |
function | add listener to an action |
offAction |
function | remove listener to an action |
- Source:
Examples
<!--
access to mapstore api
-->
<script>
window.addEventListener('mapstore:ready', function(event) {
const msAPI = event.detail;
});
</script>
<!--
use mapstore api onAction method to listen to an action
this example works only in a page with the map plugin (eg. dataset and map viewers)
-->
<script>
window.addEventListener('mapstore:ready', function(event) {
const msAPI = event.detail;
function onChangeMapView(action) {
// read parameters dispatched by the action
const center = action.center;
console.log(center);
// get all the current stored map state
const currentMapState = msAPI.getMapState();
console.log(currentMapState);
}
// listen on map view changes
msAPI.onAction('CHANGE_MAP_VIEW', onChangeMapView);
});
</script>
<!--
use mapstore api offAction method to listen to an action only once
this example works only in a page with the map plugin (eg. dataset and map viewers)
-->
<script>
window.addEventListener('mapstore:ready', function(event) {
const msAPI = event.detail;
function onChangeMapView(action) {
// read parameters dispatched by the action
const center = action.center;
console.log(center);
// ...
// remove the same action
msAPI.offAction('CHANGE_MAP_VIEW', onChangeMapView);
}
// listen on map view changes
msAPI.onAction('CHANGE_MAP_VIEW', onChangeMapView);
});
</script>
<!--
use mapstore api triggerAction method to dispatch an action
this example works only in a page with the map plugin (eg. dataset and map viewers)
-->
<button id="custom-zoom-button">Zoom to extent</button>
<script>
window.addEventListener('mapstore:ready', function(event) {
const msAPI = event.detail;
const button = document.querySelector('#custom-zoom-button');
button.addEventListener('click', function() {
msAPI.triggerAction({
type: 'ZOOM_TO_EXTENT',
crs: 'EPSG:4326',
extent: {
minx: -10,
miny: -10,
maxx: 10,
maxy: 10
}
});
});
});
</script>
(constant) getAttributeControlId
Get the attribute control id
(constant) getErrorByPath
Get the error message by path
(constant) parseJSONSchema
Parse JSON Schema and convert it to dataset attributes
(constant) parseNumber
Parse a number string to a number
(constant) validateAttributes
Validate attribute data including range values and unique names
(constant) validateSchema :Object
The JSON schema for the dataset
Type:
- Object
Methods
CreateDataset(props)
Create Dataset component.
It allows to create a new dataset by uploading a JSON schema file or by manually adding attributes.
Parameters:
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
props |
Object | The component props
Properties
|
Favorites()
Favorites button component
Properties:
| Name | Type | Description |
|---|---|---|
user |
object | user properties |
component |
class | function | a valid component |
resource |
object | resource properties |
location |
object | router location |
onSearch |
function | trigger a refresh request after changing the favorite association |
delayTime |
number | delay time to complete the request |
renderType |
string | define the component type (eg. menuItem) |