Skip to main content

Data Accessor Functions

These functions are accessible through the window.top['maptaskrCORE'] object and can be used to interact with the map application. They provide various capabilities for retrieving data, handling events, and more.

List of Available Functions

Get Drawn Shapes

Description

The getDrawnShapes function allows you to retrieve a collection of shapes currently displayed on the map in Record Level ONLY.

Usage

var drawnShapes = window.top['maptaskrCORE'][controlId].getDrawnShapes();
console.log('drawnShapes', drawnShapes);

Returns

The array of shapes currently displayed on the map.

Get Uploaded Shapes

Description

The getUploadedShapes function retrieves polygon areas from a specified file within the map in Record Level ONLY.

Usage

var uploadedShapes = window.top['maptaskrCORE'][controlId].getUploadedShapes();
console.log('uploadedShapes', uploadedShapes);

Returns

The polygon areas from all uploaded files.

Get Shape Count

Description

The getShapeCount function returns the count of polygon areas within the map in Record Level ONLY.

Usage

var shapeCount = window.top['maptaskrCORE'][controlId].getShapeCount();
console.log('shapeCount', shapeCount)

Returns

The count of drawn and uploaded shapes within the map.

Get Annotation

Description

The getAnnotation function retrieves annotations from the map in Record Level ONLY.

Usage

var annotations = window.top['maptaskrCORE'][controlId].getAnnotation();
console.log('annotations;, annotations);

Returns

Annotations from the map application.

Get Lambpet Ids

Description

The getLambpetIds function retrieves the IDs of Lambpets within the map in Record Level ONLY.

Usage

var lambpetIds = window.top['maptaskrCORE'][controlId].getLambpetIds();
console.log('annotations', annotations);

Returns

The IDs of Lambpets within the map application.

Get Uploaded Files

Description

The getUploadedFiles function retrieves a list of uploaded files within the map in Record Level ONLY.

Usage

var uploadedFiles = window.top['maptaskrCORE'][controlId].getUploadedFiles();
console.log('uploadedFiles', uploadedFiles);

Returns

A list of uploaded files within the map application.

Get Shape Intersections

Description

The getShapesIntersections function allows you to check for intersections between shapes asynchronously in Record Level ONLY.

Usage

var shapeIntersections = await window.top['maptaskrCORE'][controlId].getShapeIntersections();
console.log('shapeIntersections', shapeIntersections);

Returns

A result indicating whether there are intersections between shapes.

Get Lat Long From Coordinate

Description

The getLatLongFromCoordinate function allows you to convert a X, Y coordinate point from the return values to a Long, Lat coordinate for use elsewhere.

Usage

window.top['maptaskrCORE'][controlId].getLatLongFromCoordinate(coordinateX, coordinateY);
  • coordinateX (number): The Longitude of the coordinate (in EPSG 3857).
  • coordinateY (number): The Latitude of the coordinate (in EPSG 3857).

Returns

Function will return an object with Latitude and Longitude in WGS84 (EPSG 4326).

Description

The navigateToLatLong function allows you to programmatically position the map over a latitude and longitude with an optional Zoom level to set the zoom.

Usage

window.top['maptaskrCORE'][controlId].navigateToLatLong(latitude, longitude, zoom);
  • latitude (number): The Latitude of the coordinate (in WGS84).
  • longitude (number): The Longitude of the coordinate (in WGS84).
  • zoom (number): (Optional) The zoom level to zoom to, Leave empty to retain current zoom.

Returns

Function does not return any data. It will position the map over a given latitude and longitude coordinate.

Description

The navigateToExtent function allows you to programmatically position the map over a given extent with the optimal zoom to display the provided extent.

Usage

window.top['maptaskrCORE'][controlId].navigateToExtent(minLatitude, minLongitude, maxLatitude, maxLonitude);
  • minLatitude (number): The Minimum Latitude of the extent (in WGS84).
  • minLongitude (number): The Minimum Longitude of the extent (in WGS84).
  • maxLatitude (number): The Maximum Latitude of the extent (in WGS84).
  • maxLonitude (number): The Maximum Longitude of the extent (in WGS84).

Returns

Function does not return any data. It will position a map over a given extent.

Download Map

Description

The downloadMap function allows you to invoke the download map functionality which renders out the elements of the map in the format configured.

Usage

window.top['maptaskrCORE'][controlId].downloadMap();
  • Use this function in conjunction with the MapDownloaded event to capture the Base64 image and process it within your implementation.

Returns

Returns a base64 image for you to process.

Show Warning Message

Description

The showWarningMessage function displays a warning message within the map application for a specified duration.

Usage

window.top['maptaskrCORE'][controlId].showWarningMessage(msg, timeout);
  • msg (string): The warning message to be displayed.
  • timeout (number): The duration of the warning message to be displayed for.

Returns

This function does not return any data. It renders a warning message element on the Maptaskr control.

Handle Loading Spinner

Description

The handleLoadingSpinner function toggles the display of a loading spinner within the map application and sets a loading message.

Usage

window.top['maptaskrCORE'][controlId].handleLoadingSpinner(show, message);

Returns

This function does not return any data. It renders a loading spinner element on top of the Maptaskr control, disabling any interaction until the spinner is removed.

Update Loading Spinner Message

Description

The updateLoadingSpinnerMessage function updates the message displayed alongside the loading spinner within the map application.

Usage

window.top['maptaskrCORE'][controlId].updateLoadingSpinnerMessage(message);
  • message (string): The new message to be displayed alongside the loading spinner.

Returns

This function does not return any data. It renders the given text on the loading spinner element.

On Event

Description

The on function allows you to register event listeners for specific events within the map application.

Usage

window.top['maptaskrCORE'][controlId].on(eventName, functionCallback)
  • eventName (string): The name of the event to listen for.
  • functionCallback (function): The call-back function to be executed when the event is triggered.

Returns

This function does not return any data.

Off Event

Description

The off function removes previously registered event listeners for specific events within the map application.

Usage

window.top['maptaskrCORE'][controlId].off(eventName);

Returns

This function does not return any data.

Fire Event

Description

The fire function manually triggers a specified event within the map application, optionally passing additional data. For details on what parameters are required for specific events, please refer to the previous sections of this document.

Usage

window.top['maptaskrCORE'][controlId].fire(eventName, param, param2, ...param5);

eventName (string): The name of the event to trigger.

param (unknown): The parameter that is required for the specified event

Returns

This function does not inherently return any data, however the function that is manually triggered may return data. Please refer to the documentation for the given event.

Add Highlight

Description

The addHighlight function will generate a new polygon with your given colours to indicate a highlighted area based on a provided GeoJSON object.

Usage

window.top['maptaskrCORE'][controlId].addHighlight(geoJSON, strokeColour, fillColour);
  • geoJSON (string): GeoJSON data (in EPSG: 3857 spatial reference) to pass to the function to render as a highlight
  • strokeColour (string): stroke colour for the given shape in hex format.
  • fillColour (string): fill colour for the given shape in hex format.

Returns

This function does not return any data.

Clear Highlights

Description

The clearHighlights function will find all shapes generated via the addHighlight function and remove them from the map.

Usage

window.top['maptaskrCORE'][controlId].clearHighlights();

Returns

This function does not return any data.

Save Shapes

Description

The saveShapes function will save any changes made on the Maptaskr map to the dataverse tables.

Usage

window.top['maptaskrCORE'][controlId].saveShapes()

NOTE: If you run this function yourself, you should ensure that all shapes are valid prior to saving (which can be completed by running getShapeIntersections()) and you would ideally make the Maptaskr control read only (see section window.top.maptaskrReady(pageContext, controlId)

Returns