Skip to main content

Global Function

Maptaskr Core Loaded

window.top.maptaskrReady(pageContext, controlId)

Description

To allow you to get access to, and register events with the maptaskrCORE top window variable, we have added code to execute the window.top.maptaskrReady function to let you know the map has loaded, and is ready to have events registered.

This function will pass the pageContext (provided by D365) and a unique Control ID. This ID is the GUID of the maptaskr Instance, and can be used to reference future functions.

Usage

You will find this function pre-defined in the Custom.js file in web resources. If you wish to alter this function, please make a new Solution Layer, and upload your own Custom.js file (you can clone the existing file to extend the functionality)

/* extract from custom.js */

if (window && window.top)
window.top.maptaskrReady = function(pageContext, controlId) {
console.log("Maptaskr Map ID: " + controlId + " has Loaded");

let maptaskrControl = window && window.top && window.top.maptaskrCORE && window.top.maptaskrCORE[controlId];

if (maptaskrControl)
{
/* Use the following console logs to uniquely identify your map */
// console.log(pageContext);
// console.log(maptaskrControl.registeredLocation);
// console.log(maptaskrControl.webresourceLocation);

/* register the correct client validation function here */
maptaskrControl.clientValidationFunction = clientValidationFunction;

/* put your setup methods here */
/* e.g. maptaskrControl.disableSaving = true; */
/* this will disable the inbuilt save methods, */
/* you an use maptaskrControl.saveShapes() to save your own shapes.*/

/* put your event registrations here. */
/* e.g. maptaskrControl.on("FeaturesSelected", ...) */

}
};

Once the map control is loaded, and the object available, you can register your events, or call the Data Accessor functions.

This function also provides examples of how to use the data accessor properties from the map control to uniquely identify the form your map is loaded on. This allows you to dynamically assign the client validation function (if required) and register to select events per map.

This function also provides you with access to some special accessor variables for changing the read only state of the map, providing a custom validation function for shapes on that map control, and properties to help you uniquely identify the map control should there be multiple controls on a single page.

PropertyDescription
maptaskrControl.registeredLocationThis variable will have the URL of the current page. This is useful for identifying which entity form you are loading the map on.
maptaskrControl.webresourceLocationThis variable will have the URL of the WebResource loaded within the form. This is useful if you have any custom parameters on the web resource to identify this map.
maptaskrControl.clientValidationFunctionThis function is registered to allow you to customise the saving logic and validate the submitted shapes against custom business logic prior to saving to the Dataverse tables.
maptaskrControl.disableSavingThis is a Boolean value you can set to disable saving for this map control. It will not affect the UI in any way, however saving and the saving notifications will be disabled.